MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / processScriptBlock

Method processScriptBlock

src/extraction/vue-extractor.ts:171–229  ·  view source on GitHub ↗

* Process a script block by delegating to TreeSitterExtractor

(
    block: { content: string; startLine: number; isSetup: boolean; isTypeScript: boolean },
    componentNodeId: string
  )

Source from the content-addressed store, hash-verified

169 * Process a script block by delegating to TreeSitterExtractor
170 */
171 private processScriptBlock(
172 block: { content: string; startLine: number; isSetup: boolean; isTypeScript: boolean },
173 componentNodeId: string
174 ): void {
175 const scriptLanguage: Language = block.isTypeScript ? 'typescript' : 'javascript';
176
177 // Check if the script language parser is available
178 if (!isLanguageSupported(scriptLanguage)) {
179 this.errors.push({
180 message: `Parser for ${scriptLanguage} not available, cannot parse Vue script block`,
181 severity: 'warning',
182 });
183 return;
184 }
185
186 // Delegate to TreeSitterExtractor
187 const extractor = new TreeSitterExtractor(this.filePath, block.content, scriptLanguage);
188 const result = extractor.extract();
189
190 // Offset line numbers from script block back to .vue file positions
191 for (const node of result.nodes) {
192 node.startLine += block.startLine;
193 node.endLine += block.startLine;
194 node.language = 'vue'; // Mark as vue, not TS/JS
195
196 this.nodes.push(node);
197
198 // Add containment edge from component to this node
199 this.edges.push({
200 source: componentNodeId,
201 target: node.id,
202 kind: 'contains',
203 });
204 }
205
206 // Offset edges (they reference line numbers)
207 for (const edge of result.edges) {
208 if (edge.line) {
209 edge.line += block.startLine;
210 }
211 this.edges.push(edge);
212 }
213
214 // Offset unresolved references
215 for (const ref of result.unresolvedReferences) {
216 ref.line += block.startLine;
217 ref.filePath = this.filePath;
218 ref.language = 'vue';
219 this.unresolvedReferences.push(ref);
220 }
221
222 // Carry over errors
223 for (const error of result.errors) {
224 if (error.line) {
225 error.line += block.startLine;
226 }
227 this.errors.push(error);
228 }

Callers 1

extractMethod · 0.95

Calls 2

extractMethod · 0.95
isLanguageSupportedFunction · 0.90

Tested by

no test coverage detected