-
Notifications
You must be signed in to change notification settings - Fork 19
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
Remove the CST Visitor API #665
Conversation
...and use the borrowing variant for the NAPI `pathRuleNodes` function to not double-allocate. The borrowing variant is more general in the Rust API; not all use cases want or should rely on previously collecting the path into a Vec of owned `Rc`s.
In preparation to remove the CST `Visitor` trait altogether.
🦋 Changeset detectedLatest commit: f705de9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@@ -60,5 +60,5 @@ Tree: | |||
- PathImport (Rule): # 30..40 ' "foo.sol"' | |||
- AsciiStringLiteral (Token): '"foo.sol"' # 31..40 | |||
- Semicolon (Token): ";" # 40..41 | |||
- EndOfFileTrivia (Rule): "\n" # 42..43 | |||
- EndOfFileTrivia (Rule): # 42..43 "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, the TestNodeBuilder
would not construct the whitespace children tokens and the printer logic would recognize this as an childless node, whereas the new printer does not, as we only skipped the leading/trailing trivia nodes before.
This should probably be fixed to also not include the EndOfFileTrivia
much like the Leading/Trailing variants, however this is not as important as we will change the trivia model soon (DSL v2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 47663c9 for the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a few suggestions.
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/[email protected] ### Minor Changes - [#699](#699) [`ddfebfe9`](ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - [#699](#699) [`ddfebfe9`](ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - [#665](#665) [`4b5f8b46`](4b5f8b4) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - [#666](#666) [`0434b68c`](0434b68) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - [#675](#675) [`daea4b7f`](daea4b7) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - [#676](#676) [`b496d361`](b496d36) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. ### Patch Changes - [#685](#685) [`b5fca94a`](b5fca94) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - [#660](#660) [`97028991`](9702899) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
We discussed internally that the Visitor API for (dynamically typed) CST is a lot less useful now that we have the
Iterator
interface implemented in Rust (and hopefullyIterator
protocol in TS in the future), so let's remove the CST Visitor API altogether.The Visitor pattern will be a lot useful once we have typed, heterogenous data such as the new AST (#634), so let's wait until then with designing and exposing such interface.