-
-
Notifications
You must be signed in to change notification settings - Fork 658
feat(napi/parser): add AST walker #13930
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
d07fa71
to
1c50c58
Compare
a44ba52
to
f68cffb
Compare
1c50c58
to
098ac21
Compare
f68cffb
to
f7f9e3a
Compare
098ac21
to
c2b060a
Compare
c2b060a
to
4eb80fe
Compare
4eb80fe
to
c8131c1
Compare
f7f9e3a
to
b0abdfd
Compare
This was referenced Sep 20, 2025
c8131c1
to
da2c6f6
Compare
b0abdfd
to
7091e82
Compare
da2c6f6
to
488d5b2
Compare
fe80787
to
2395e3a
Compare
0800b58
to
bfd6ca6
Compare
2395e3a
to
2bd7aa7
Compare
Merge activity
|
Add an AST visitor to `oxc-parser`. ```js import { parseSync, Visitor } from 'oxc-parser'; const { program } = parseSync('test.js', 'let x = { y: z };'); const idents = []; const visitor = new Visitor({ Identifier(node) { idents.push(node.name); } }); visitor.visit(program); // Logs [ 'x', 'y', 'z' ] console.log(idents); ``` Primarily we need a visitor for Oxlint plugins, but it's easier to develop and test in `oxc-parser`, so I thought I'd add it there first. Oxlint build process will copy the generated files for tree-walking from `napi/parser` dir, as it does with other files. Notes: * The `walk.mjs` file is large, so it's lazy-loaded only when user first constructs a `Visitor`. Adding `Visitor` to the package will not affect start-up time where user only uses `parseSync` etc. * TS type definition for `Visitor` and the visitor object it takes are provided. * Visitor supports enter and exit visitors e.g. `Program` and `Program:exit`. * `src-js/visit/visitor.mjs` is copied from `apps/oxlint` with only minor modifications, and conversion from TS to JS. It'd be better if we only had this impl in one place, but that would require converting `oxc-parser` to TS and building with TSDown, like `oxlint` is. Leaving that for later - #13935.
2bd7aa7
to
4ee94a3
Compare
bfd6ca6
to
56a385f
Compare
Base automatically changed from
09-17-feat_napi_parser_export_visitor_keys
to
main
September 22, 2025 11:14
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an AST visitor to
oxc-parser
.Primarily we need a visitor for Oxlint plugins, but it's easier to develop and test in
oxc-parser
, so I thought I'd add it there first. Oxlint build process will copy the generated files for tree-walking fromnapi/parser
dir, as it does with other files.Notes:
walk.mjs
file is large, so it's lazy-loaded only when user first constructs aVisitor
. AddingVisitor
to the package will not affect start-up time where user only usesparseSync
etc.Visitor
and the visitor object it takes are provided.Program
andProgram:exit
.src-js/visit/visitor.mjs
is copied fromapps/oxlint
with only minor modifications, and conversion from TS to JS. It'd be better if we only had this impl in one place, but that would require convertingoxc-parser
to TS and building with TSDown, likeoxlint
is. Leaving that for later - Convertoxc-parser
to TypeScript #13935.