Skip to content

Svelte <script> function/call symbols never extracted — component call-graph is empty (imports work per #223, calls don't; Svelte analog of #1410) #1807

Description

@lcclcoder

Summary

For .svelte components, the <script>/<script lang="ts"> block is parsed structurally but its function definitions and call sites are never emitted as graph symbols. Each component yields only File + Module nodes. Imports are extracted (thanks to #223/#224) and SvelteKit routes too (#369), but the call graph inside components is absent.

This is the Svelte analog of #1410 (Vue <script setup>), with the same consequence: incomplete call graph and false-positive dead-code for component logic.

Environment

  • v0.10.8, macOS arm64 (darwin), npm install
  • tree-sitter Svelte grammar present (parses script_element)

Repro

  1. Index any repo containing a .svelte component whose <script lang="ts"> defines named functions (e.g. function toggleOpen() {…}).
  2. Query the graph:
    query_graph  MATCH (f:Function) WHERE f.file_path ENDS WITH '.svelte' RETURN count(*)
    query_graph  MATCH (n) WHERE n.file_path ENDS WITH '.svelte' RETURN n.name, labels(n)
    

Observed

Real-world index (a SvelteKit app, 294 components): 294/294 components have File+Module nodes and import edges, but zero <script>-internal function or call symbols.

Expected

<script> bodies re-parsed as JS/TS (language injection on script_element → TS grammar), with normal symbol + CALLS/DEFINES extraction and line offsets mapped back to the component — matching what already happens for a .ts file.

Evidence that injection is sufficient

Extracting a component's <script> verbatim into a sibling .ts file makes the same functions appear as full Function nodes with call edges:

Source Function nodes emitted
TreeNode.svelte (toggleOpen, transformDataForRecursiveTree in <script>) 0
identical body extracted to TreeNode.script.ts 2 (both, with edges)

So the grammar + extractor already handle the code — only the injection step from script_element into TS symbol/call extraction is missing (the imports path added in #223 is the precedent).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions