fix(extract): extract structure from Svelte/HTML/Astro inline scripts - #2056
Open
bmcnaboe wants to merge 2 commits into
Open
fix(extract): extract structure from Svelte/HTML/Astro inline scripts#2056bmcnaboe wants to merge 2 commits into
bmcnaboe wants to merge 2 commits into
Conversation
The Vue change (DeusData#1852) built the shared embedded-script seam — the included-ranges parse over the original buffer and the lang=/src= resolver — but gated structural extraction on the host being Vue. A Svelte component, an HTML page or an Astro file therefore still yielded only File + Module nodes and IMPORTS edges from its <script> blocks: no Function definitions, no CALLS, and a false dead-code verdict for anything used only from a component. Widen the seam to every host that declares an embedded spec: - Structural extraction (definitions + calls) runs for every embedded block; the per-host boolean is gone. - The Vue attribute resolver becomes script_embedded_language() and runs for all four markup hosts. It starts from the spec row's language instead of hard-coding JavaScript, and learns HTML's type= attribute: absent or empty, module, text/javascript and application/javascript pass; application/json, importmap, text/x-template and the like bail, so data blocks cannot leak garbage definitions into the graph. src= and unsupported lang= values bail as before. CFML's <cfscript> carries no attributes and keeps its spec-fixed language. - Astro's frontmatter fence and <script> bodies default to TypeScript: Astro type-checks both as TS with no lang= attribute to say so, and the fence cannot carry one. The TypeScript grammar parses untyped JavaScript unchanged. Tests: the DeusData#1852 control that pinned Svelte/HTML/Astro at zero functions and zero calls now asserts the real symbols; stay-at-zero controls cover type="application/json" and <script src> in every host; both Svelte blocks (context="module", and Svelte 5's bare module) contribute in host-file coordinates; HTML's accepted type= forms and Astro's TS frontmatter are covered; an end-to-end CALLS edge inside a .svelte file is asserted. The Svelte and Astro label goldens gain the Variable their fixtures always declared. Verified on a 213-component Vue corpus: node counts per label and per host language, edge counts and trace_path output are identical before and after. Fixes DeusData#1807 Signed-off-by: Brian McNaboe <bmcnaboe@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
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.
Fixes #1807. Follow-up to #1852, carrying the generalization agreed on #1410.
What it does
#1852 built the shared embedded-script seam (included-ranges parse over the original buffer,
lang=/src=resolution) and gated structural extraction to Vue. This widens it: Svelte, HTML and Astro<script>blocks — and Astro's frontmatter fence — now yieldFunctiondefinitions andCALLSedges in host-file coordinates, exactly as a standalone.ts/.jsfile does.Concretely, in
internal/cbm/extract_imports.candinternal/cbm/lang_specs.c:extract_structureboolean is gone; every embedded block extracts definitions, imports and calls.vue_embedded_language()is nowscript_embedded_language()and runs for all four markup hosts. It starts from the spec row's language rather than hard-coding JavaScript, so an attribute-free block keeps its declared grammar. It also learns HTML'stype=: absent/empty,module,text/javascriptandapplication/javascriptpass;application/json,importmap,text/x-template,application/ld+jsonand anything else bail, so data blocks cannot leak garbage definitions.src=and unsupportedlang=bail as before.<cfscript>carries no attributes and keeps its spec-fixed language (the resolver is not consulted for it).<script>bodies default to TypeScript, deliberately: Astro type-checks both as TS with nolang=attribute to say so, and the fence cannot carry one. The TypeScript grammar parses untyped JavaScript unchanged.Tests
embedded_structure_sibling_hosts_issue1807).<script type="application/json">and<script src>in every host, plusimportmapandtext/x-templatefor HTML (embedded_structure_inert_blocks_issue1807). HTML's own tag walker still records thesrc=reference as an import edge; that names the external file and is asserted explicitly.<script context="module">and Svelte 5's baremodule— with per-blocklang=and host-file line numbers (svelte_embedded_structure_both_blocks_issue1807).type=forms with line numbers, and a data block on the same page ignored (html_embedded_structure_issue1807).<script>body, both in host-file coordinates (astro_embedded_structure_issue1807).CALLSedge inside a.sveltefile, the exact shape Svelte <script> function/call symbols never extracted — component call-graph is empty (imports work per #223, calls don't; Svelte analog of #1410) #1807 reports missing (es_calls_svelte_embedded_issue1807).Variabletheir fixtures always declared (test_grammar_labels.c).Validation
Indexed a 213-component Vue corpus (~26k nodes, ~75k edges) with
mainand with this branch, isolated caches: node counts per label, per host extension (.vue,.html,.ts),CALLS/IMPORTScounts per extension, andtrace_pathoutput for Vue-defined functions are identical. Vue behaviour is unchanged.scripts/test.shandscripts/lint.share green locally. DCO signed.