Files
codebase-memory-mcp/tests
Martin VogelandJames 30941983cb fix(imports): extract ES imports from embedded <script> blocks (#224)
Generalizes #224's Svelte/Vue script-block import extraction into a
spec-driven embedded-language pattern that also covers HTML and Astro,
so any future host grammar that keeps sub-language source as raw text
gets coverage with a one-line declaration.

The existing CBMLangSpec already exposes the per-language tree-sitter
grammar via cbm_ts_language(); add a parallel embedded_imports field
that lists which AST node types hold which sub-language. The new
generic walker in extract_imports.c reads that list, locates each
embedded content node in the host AST, re-parses the slice with the
embedded grammar resolved through cbm_ts_language(), and runs the
standard ES import extractor (walk_es_imports) over the inner AST.
No grammar symbols are referenced from the extraction file.

- internal/cbm/lang_specs.h: add CBMEmbeddedLangSpec + embedded_imports
  field on CBMLangSpec.
- internal/cbm/lang_specs.c: declare vue/svelte/html/astro embed lists
  ({"script_element", "raw_text", CBM_LANG_JAVASCRIPT}); set the new
  field on those four spec entries; explicit NULL initializer on every
  other entry to satisfy -Wmissing-field-initializers.
- internal/cbm/extract_imports.c: add embedded_collect_content_nodes
  + parse_embedded_imports; route SVELTE/VUE/HTML/ASTRO through the
  generic helper.
- tests/test_extraction.c: cover Svelte (with and without <script>),
  Vue, and HTML.

Full suite: 2824 passed, 0 failed.

Closes #223. Closes #224.

Co-authored-by: James <jmcmacnz@gmail.com>
2026-05-08 23:04:33 +02:00
..
2026-04-15 23:56:03 +02:00