Skip to content

Add Vue and Svelte single-file component support - #712

Closed
Zhey-on wants to merge 1 commit into
CodeGraphContext:mainfrom
Zhey-on:feat/issue-709-vue-svelte
Closed

Zhey-on wants to merge 1 commit into
CodeGraphContext:mainfrom
Zhey-on:feat/issue-709-vue-svelte

Conversation

@Zhey-on

@Zhey-on Zhey-on commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds first-class support for Vue and Svelte single-file components.

  • Added .vue and .svelte routing in the graph builder
  • Implemented dedicated Vue/Svelte parsers that extract <script> blocks
  • Reused existing JavaScript/TypeScript parsers for script analysis
  • Preserved original file line numbers with offset remapping
  • Added SFC pre-scan support so symbol resolution works across files
  • Updated language aliases, tool language enums, docs, and parser smoke tests

Why this approach

Vue and Svelte files mix template markup with script code. Instead of trying to parse every SFC construct as a new language model, this keeps code analysis focused on script sections and reuses the mature JS/TS logic that is already in the project.

Validation

  • ./tests/run_tests.sh fast -> passed (69 passed, 2 skipped)
  • pytest -q tests/unit/parsers/test_sfc_parsers.py
  • python3 scripts/test_all_parsers.py

Closes #709

Adds .vue and .svelte indexing by extracting script blocks and parsing them with JS/TS parsers, including line remapping for original files.

Also wires extension routing, pre-scan symbol collection, package language enums/docs, and parser coverage tests.

Closes #709
@vercel

vercel Bot commented Mar 13, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

mannyyang added a commit to datatorag/CodeGraphContext that referenced this pull request Apr 9, 2026
Replace the inline Vue hack (regex + temp file) with dedicated SFC
parsers based on CodeGraphContext#712:

- sfc_common.py: SharedSingleFileComponentTreeSitterParser base class
  - Multi-block support (<script> + <script setup>)
  - lang="ts" detection → routes to TypeScript parser
  - Line offset remapping → line numbers point to original .vue file
  - No temp files — parses script content in-memory
  - Dedicated pre_scan for cross-file import resolution
- vue.py: VueTreeSitterParser subclass
- svelte.py: SvelteTreeSitterParser subclass (new language support)

Removed: _extract_vue_script, temp file creation in parse_file

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Zhey-on Zhey-on closed this by deleting the head repository May 30, 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.

Add support for Svelte and Vue

1 participant