Skip to content

Add parseWithComments with correct span serialization#19

Merged
guan404ming merged 2 commits intoguan404ming:mainfrom
elliots:feat/spans-and-comments
Mar 21, 2026
Merged

Add parseWithComments with correct span serialization#19
guan404ming merged 2 commits intoguan404ming:mainfrom
elliots:feat/spans-and-comments

Conversation

@elliots
Copy link
Contributor

@elliots elliots commented Mar 19, 2026

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 parseWithComments API (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-sys to 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.

@guan404ming
Copy link
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.

@elliots elliots force-pushed the feat/spans-and-comments branch from 7a1105e to a0131a6 Compare March 21, 2026 07:47
@elliots elliots force-pushed the feat/spans-and-comments branch from a0131a6 to ab0cfae Compare March 21, 2026 07:48
@elliots
Copy link
Contributor Author

elliots commented Mar 21, 2026

I believe, all fixed.

Copy link
Owner

@guan404ming guan404ming left a comment

Choose a reason for hiding this comment

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

Thanks for the update

@guan404ming guan404ming merged commit 6ae6f31 into guan404ming:main Mar 21, 2026
3 checks passed
@guan404ming guan404ming changed the title comments and spans Add parseWithComments with correct span serialization Mar 21, 2026
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.

3 participants