From 9ee6718ad195c4be422614032a869196de705c5f Mon Sep 17 00:00:00 2001 From: Colby Mchenry Date: Fri, 23 Oct 2026 03:37:25 +0000 Subject: [PATCH] fix(vue): a +`, + // Types and JSX together, which only the TSX grammar reads. + 'src/Card.vue': ` +`, + // Controls: TypeScript stays TypeScript, no lang stays JavaScript. + 'src/Plain.vue': ` + +`, + 'src/Legacy.vue': ` + +`, +}; + +let roots: string[] = []; +let graphs: CodeGraph[] = []; + +afterEach(() => { + for (const graph of graphs) graph.close(); + graphs = []; + for (const root of roots) fs.rmSync(root, { recursive: true, force: true }); + roots = []; +}); + +async function indexProject(): Promise { + const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-vue-tsx-')); + roots.push(root); + for (const [file, text] of Object.entries(PROJECT)) { + fs.mkdirSync(path.dirname(path.join(root, file)), { recursive: true }); + fs.writeFileSync(path.join(root, file), text); + } + const graph = await CodeGraph.init(root, { index: true }); + graphs.push(graph); + return graph; +} + +const named = (nodes: Node[], kind: string, name: string) => nodes.find((n) => n.kind === kind && n.name === name); + +/** + * The file's extraction errors. The file must be stored: one whose grammar + * was not loaded is never parsed, and nothing at all is stored for it. + */ +function errorsOf(graph: CodeGraph, file: string) { + const record = graph.getFile(file); + expect(record, `${file} is stored`).not.toBeNull(); + return record!.errors ?? []; +} + +describe('Vue \n', 'svelte')).toEqual(['javascript']); + }); +}); diff --git a/src/extraction/grammars.ts b/src/extraction/grammars.ts index e405adcc..66c69687 100644 --- a/src/extraction/grammars.ts +++ b/src/extraction/grammars.ts @@ -463,7 +463,9 @@ function resolveWasmPath(lang: GrammarLanguage): string { * SFC languages (svelte/vue/astro) have no grammar of their own — their * extractors delegate