Skip to content

feat: add Svelte and Vue (SFC) language support - #1289

Merged
Shashankss1205 merged 3 commits into
CodeGraphContext:mainfrom
youdie006:feat/svelte-vue-support
Jul 31, 2026
Merged

Shashankss1205 merged 3 commits into
CodeGraphContext:mainfrom
youdie006:feat/svelte-vue-support

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

Summary

.svelte and .vue files were not indexed because there were no parsers for them (#709).

Fix

Add Svelte and Vue single-file-component support to the AST indexer:

  • tools/languages/sfc_common.py: splits the SFC into <script>/<template>/<style>, detects lang="ts", and pads the script block with leading blank lines so the delegated JavaScript/TypeScript parser's line numbers map back to the SFC with no per-symbol arithmetic.
  • tools/languages/svelte.py, vue.py: thin parser classes mirroring the existing html.py shape; script extraction delegates to the JS/TS parsers.
  • Registered in the tree-sitter manager, parser dispatch, graph builder (.svelte/.vue -> language), and pre-scan. Grammars load from tree-sitter-language-pack.

Adds SFC parser unit tests (script symbols, TS scripts, dispatch, pre-scan).

Closes #709

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@youdie006 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Shashankss1205

Copy link
Copy Markdown
Collaborator

👋 Thanks for contributing to CodeGraphContext! Since this PR was opened, main has moved forward significantly (we just shipped v0.5.2 and merged ~50 PRs), so this one now has merge conflicts. Could you please rebase onto the latest main and resolve the conflicts? Once it is conflict-free and CI is green, we will review and merge it. Really appreciate your work — thank you! 🙏

Add .svelte and .vue parsers to the AST indexer. A shared sfc_common helper
splits the single-file component into <script>/<template>/<style>, detects
lang=ts, and pads the script block so the delegated JavaScript/TypeScript
parser line numbers map back to the SFC. svelte.py and vue.py mirror the
existing html.py module shape and register in the tree-sitter manager, parser
dispatch, graph builder, and pre-scan. Grammars load from
tree-sitter-language-pack. Adds SFC parser unit tests.

Closes CodeGraphContext#709
@youdie006
youdie006 force-pushed the feat/svelte-vue-support branch from 714cdb1 to 34a250e Compare July 27, 2026 05:28
@youdie006

Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up, @Shashankss1205! Rebased onto the latest main (past v0.5.2). The only conflict was in tree_sitter_parser.py, where main replaced the if/elif dispatch with the data-driven LANGUAGE_PARSER_MAP - I dropped my old elif branches and registered svelte/vue in the map instead, so the change is now a 2-line addition there. All 173 parser unit tests pass locally, including the SFC dispatch tests. Ready for review.

Shashankss1205 and others added 2 commits July 31, 2026 23:28
A non-UTF-8 .vue/.svelte file must degrade to lost bytes, not a lost file;
tests/unit/tools/test_parser_encoding_resilience.py enforces this for all
language parsers.

Co-Authored-By: Claude Fable 5 <[email protected]>
…heck scans every open( call

Co-Authored-By: Claude Fable 5 <[email protected]>

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed and verified locally — parser + tools suites green after two tiny follow-up commits I pushed to your branch (errors="ignore" on the SFC read/write handles, required by our parser encoding-resilience check). Really nice design delegating to the JS/TS parsers with line padding.

@Shashankss1205
Shashankss1205 merged commit a07d31e into CodeGraphContext:main Jul 31, 2026
1 check failed
@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Jul 31, 2026
@Shashankss1205

Copy link
Copy Markdown
Collaborator

Thanks @youdie006 for this contribution — merged! 🎉 Svelte and Vue support is a great addition, and the SFC delegation design is elegant. We'd love to have you contribute back again — feel free to pick up another open issue!

@Shashankss1205 Shashankss1205 added gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:feature GSSoC type bonus: feature labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:feature GSSoC type bonus: feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add support for Svelte and Vue

2 participants