feat(index): Svelte support + TS arrow function extraction - #390
Merged
Conversation
Phase 1 - TS arrow functions:
- Capture exported const arrow functions: export const handler = () => {}
- Capture function expressions: const cb = function doStuff() {}
- Extract call edges from arrow function bodies
Phase 2 - Svelte support:
- Extract <script> blocks from .svelte files via regex
- Parse extracted content as TypeScript/JavaScript
- Support lang=ts and lang=js attributes
- Handle inline and multi-line script blocks
- Correct line number offset adjustment
- Zero new dependencies (reuses tree-sitter-typescript)
Tests:
- 7 new tests: arrow functions, function expressions, Svelte basic,
line numbers, no-script, JS lang, inline script
- Updated existing Svelte test for AST behavior
- 739/740 pass (1 pre-existing Ruby test failure)
Real-world validated on cora-api SvelteKit project (86 .svelte files).
+13 symbols indexed in cora-code itself from arrow functions.
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.
Summary
Closes #384 — adds Svelte support and TS arrow function extraction to the AST indexer.
Phase 1: TS Arrow Functions
Previously,
lexical_declarationandvariable_declarationonly captured ALL_CAPS constants. Now also captures:export const handler = () => { ... }const cb = function doStuff() { ... }extract_calls_from_node)Phase 2: Svelte Support
No
tree-sitter-sveltedependency needed. Instead:<script>blocks from.sveltefiles via regexlang="ts"/lang="js"attribute (default: JS)tree-sitter-typescript/tree-sitter-javascriptgrammar<script>code</script>) and multi-line script blocksWhat's NOT captured (expected)
$state,$derived,$props) — not valid TS/JS syntaxonclick={handler}) — HTML template is not parsedTest Results
.sveltefiles indexed.tsfiles captured (SvelteKitloadfunctions)Files Changed
src/index/ast.rs—extract_svelte(), arrow function support inextract_typescript(), 7 testssrc/index/extract.rs— Svelte bypass in 3get_language()gates, updated Svelte testCargo.toml— version bump to 0.8.3