MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract

Method extract

src/extraction/astro-extractor.ts:44–85  ·  view source on GitHub ↗

* Extract from Astro source

()

Source from the content-addressed store, hash-verified

42 * Extract from Astro source
43 */
44 extract(): ExtractionResult {
45 const startTime = Date.now();
46
47 try {
48 // Create component node for the .astro file itself
49 const componentNode = this.createComponentNode();
50
51 // Extract and process the frontmatter block (--- fenced, TypeScript)
52 const frontmatter = this.extractFrontmatter();
53 if (frontmatter) {
54 this.processScriptContent(frontmatter, componentNode.id, 'frontmatter');
55 }
56
57 // Extract and process <script> blocks (client-side, TypeScript-capable)
58 for (const block of this.extractScriptBlocks()) {
59 this.processScriptContent(block, componentNode.id, 'script');
60 }
61
62 // Ranges the template scans must skip: frontmatter + <script>/<style>
63 const coveredRanges = this.getCoveredRanges(frontmatter);
64
65 // Extract function calls from template expressions ({fn(...)})
66 this.extractTemplateCalls(componentNode.id, coveredRanges);
67
68 // Extract component usages from template (<ComponentName>)
69 this.extractTemplateComponents(componentNode.id, coveredRanges);
70 } catch (error) {
71 this.errors.push({
72 message: `Astro extraction error: ${error instanceof Error ? error.message : String(error)}`,
73 severity: 'error',
74 code: 'parse_error',
75 });
76 }
77
78 return {
79 nodes: this.nodes,
80 edges: this.edges,
81 unresolvedReferences: this.unresolvedReferences,
82 errors: this.errors,
83 durationMs: Date.now() - startTime,
84 };
85 }
86
87 /**
88 * Create a component node for the .astro file

Callers

nothing calls this directly

Calls 7

createComponentNodeMethod · 0.95
extractFrontmatterMethod · 0.95
processScriptContentMethod · 0.95
extractScriptBlocksMethod · 0.95
getCoveredRangesMethod · 0.95
extractTemplateCallsMethod · 0.95

Tested by

no test coverage detected