Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Diagnostic type and remove ariadne from public API #963

Merged
merged 18 commits into from
May 27, 2024

Conversation

Xanewok
Copy link
Contributor

@Xanewok Xanewok commented May 15, 2024

Part of or might close #804

Rather than coming up with perfect API that ties everything together, let's start with the Diagnostic and iterate from there.

@Xanewok Xanewok requested a review from a team as a code owner May 15, 2024 09:57
Copy link

changeset-bot bot commented May 15, 2024

🦋 Changeset detected

Latest commit: 4e85c4d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/slang Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Xanewok
Copy link
Contributor Author

Xanewok commented May 15, 2024

I have to rebase this as #962 landed in the meantime.

@@ -33,7 +33,9 @@ required-features = ["cli"]

[features]
default = ["cli"]
cli = ["dep:anyhow", "dep:clap", "dep:serde_json"]
cli = ["dep:anyhow", "dep:clap", "dep:serde_json", "__private_ariadne"]
# This is meant to be used by the CLI or internally only.
Copy link
Collaborator

@OmarTawfik OmarTawfik May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I wonder why are we adding an extra feature here, instead of just adding dep:ariadne to the existing default cli feature (enabled by default). This will also mean that we won't need to explicitly enable it in other crates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the comment, because it's also used internally (by our other crates crates in the workspace) and not only via the CLI, see https://github.com/NomicFoundation/slang/pull/963/files#diff-059ed3ad7d6d34ada23bb6a205ff05636f0f434ff9fa8ebf7c1a0c596b81b893R22 for instance.

Copy link
Collaborator

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really exciting! Thank you!
I left a few questions/suggestions.

github-merge-queue bot pushed a commit that referenced this pull request May 20, 2024
#964)

Extracted from #963 in case we want to land this separately.
@Xanewok
Copy link
Contributor Author

Xanewok commented May 27, 2024

I've resolved your final concerns @OmarTawfik:

  1. The Diagnostic::range was renamed to Diagnostic::text_range. Until we emit LSP-compliant structure there, we might as well use our local TextRange for now, which should keep using text_range
  2. The explicit toDiagnostic conversion method was removed in favor of our custom, hand-rolled interface DiagnosticsInterface (not to mix with the existing Diagnostic trait), which the exported ParseError directly implements via a new delegating macro for this trait.

We might decide to get rid of the napi-exported class Diagnostic in favour of this interface or we might keep it if we will somehow get to use the planned class inheritance feature for napi (see #987, which tracks this workaround/approach of ours), but I prefer that we treat this as further refinement of this API done only on top of this PR.

@Xanewok Xanewok added this pull request to the merge queue May 27, 2024
Merged via the queue into NomicFoundation:main with commit a5593f9 May 27, 2024
1 check passed
@Xanewok Xanewok deleted the diagnostic-api branch May 27, 2024 13:09
@github-actions github-actions bot mentioned this pull request May 30, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 11, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @nomicfoundation/slang@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-darwin-arm64@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-darwin-x64@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-linux-arm64-gnu@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-linux-arm64-musl@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-linux-x64-gnu@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-linux-x64-musl@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-win32-arm64-msvc@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-win32-ia32-msvc@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

## @nomicfoundation/slang-win32-x64-msvc@0.15.0

### Minor Changes

- [#975](#975)
[`46b1dde`](46b1dde)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename
`QueryResult` to `QueryMatch`, and its `bindings` to `captures`.

- [#971](#971)
[`be943b7`](be943b7)
Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to
`NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to
`EdgeLabel`.

- [#963](#963)
[`a5593f9`](a5593f9)
Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a
`Diagnostic` API for compiler errors, warnings etc.

### Patch Changes

- [#996](#996)
[`cdc153d`](cdc153d)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for
version `0.8.26`.

- [#983](#983)
[`ea31417`](ea31417)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language
root non-terminal kind at `Language.rootKind()`.

- [#965](#965)
[`61b6b06`](61b6b06)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST
building and querying utilities into a separate `metaslang_cst` crate.

- [#997](#997)
[`84ad856`](84ad856)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack
assignments in Yul before `0.5.0`.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors API
3 participants