Add parseWithComments with correct span serialization#19
Merged
guan404ming merged 2 commits intoguan404ming:mainfrom Mar 21, 2026
Merged
Add parseWithComments with correct span serialization#19guan404ming merged 2 commits intoguan404ming:mainfrom
guan404ming merged 2 commits intoguan404ming:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for extracting source comments (with spans/locations) alongside the parsed SQL AST, exposing the functionality through the TS API and WASM bindings.
Changes:
- Expose a new
parseWithCommentsAPI (instance, static, and top-level) that returns{ statements, comments }. - Add TypeScript types for returned comments/spans and export them from the public types barrel.
- Update the Rust WASM layer to parse comments and to tokenize with location info; add
js-systo construct the JS return object.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wasm.ts | Extends the WasmModule interface with parse_sql_with_comments. |
| src/types/index.ts | Re-exports the new comments types. |
| src/types/comments.ts | Adds SourceComment and ParseWithCommentsResult public types. |
| src/parser.ts | Adds parseWithComments APIs (instance/static/top-level) calling the new WASM export. |
| src/lib.rs | Adds parse_sql_with_comments WASM export; switches tokenization to include locations. |
| src/index.ts | Re-exports parseWithComments from the package entrypoint. |
| Cargo.toml | Adds js-sys dependency for JS object construction in WASM. |
| Cargo.lock | Locks js-sys addition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Hi @elliots thanks for your contribution. Could you help handle those review comments and also the pre-commit issue? I'm happy to merge this after that. |
7a1105e to
a0131a6
Compare
a0131a6 to
ab0cfae
Compare
Contributor
Author
|
I believe, all fixed. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Allows access to comments, and provides correct spans (so i can find what the comments are referring to)
How
Exposes the parseWithComments function, and uses tokenize_with_location
NOTE: claude did this. I'm using it, so it seemingly works ok, but just a heads-up.