feat(extraction+resolution): Astro support — frontmatter/template extraction + src/pages routes (#768) (#815)
.astro files were not indexed at all, leaving a typical Astro site mostly
invisible to search/impact/explore. New AstroExtractor (Svelte/Vue SFC
pattern): component node per file, TS frontmatter + <script> blocks
delegated to the TypeScript extractor, template {fn(...)} calls (incl. the
multiline `{posts.map((post) => (` opening line), PascalCase component-tag
references. New astroResolver: Astro global + astro:* virtual modules as
framework-provided, component resolution with the #764 ambiguity rule,
src/pages/ file-based routes ([param]→:param, [...rest]→*rest, _-prefixed
and *.config.* excluded). SFC languages now preload the TS/JS grammars
their extractors delegate to (a pure-SFC file set previously had none
loaded). Also fixes a pre-existing Svelte/Vue script-block off-by-one that
reported every script symbol one line low.
Validated per the playbook: stalux (the issue's repro) 54/54 .astro files
indexed, getIconNode found at its exact line, 14/14 routes, 93.0% fair
cross-file coverage; AstroPaper 27/27 components, 13/13 routes (underscore
dirs correctly excluded), explore connects page→Card→Datetime through the
jsx-render synthesizer; node/edge counts stable across re-syncs.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
763ee9c825
commit
823ffd1c3d
@@ -135,13 +135,16 @@ export class SvelteExtractor {
|
||||
// Detect module script
|
||||
const isModule = /context\s*=\s*["']module["']/.test(attrs);
|
||||
|
||||
// Calculate start line of the script content (line after <script>)
|
||||
// Calculate the 0-indexed line where the content begins. The content
|
||||
// starts right after the opening tag's `>` — its leading `\n` is part
|
||||
// of the content, so relative line 1 sits ON the tag's closing line
|
||||
// (adding 1 here double-counted the embedded newline and shifted every
|
||||
// script-block symbol down a line).
|
||||
const beforeScript = this.source.substring(0, match.index);
|
||||
const scriptTagLine = (beforeScript.match(/\n/g) || []).length;
|
||||
// The content starts on the line after the opening <script> tag
|
||||
const openingTag = match[0].substring(0, match[0].indexOf('>') + 1);
|
||||
const openingTagLines = (openingTag.match(/\n/g) || []).length;
|
||||
const contentStartLine = scriptTagLine + openingTagLines + 1; // 0-indexed line
|
||||
const contentStartLine = scriptTagLine + openingTagLines; // 0-indexed line
|
||||
|
||||
blocks.push({
|
||||
content,
|
||||
|
||||
Reference in New Issue
Block a user