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

Method processCodeBlocks

src/extraction/razor-extractor.ts:261–288  ·  view source on GitHub ↗

* Delegate each `@code`/`@functions`/`@{` block's C# to the tree-sitter C# * extractor and attribute the block's external references (service/DTO calls, * `new X()`, type uses) to the component. The block is wrapped in a synthetic * class so tree-sitter parses the component's fields/methods

(componentId: string)

Source from the content-addressed store, hash-verified

259 * types, not per-member nodes. Degrades gracefully if the C# grammar isn't loaded.
260 */
261 private processCodeBlocks(componentId: string): void {
262 if (!isLanguageSupported('csharp')) return;
263 for (const block of this.extractCodeBlocks()) {
264 if (!block.content.trim()) continue;
265 let result: ExtractionResult;
266 try {
267 result = new TreeSitterExtractor(
268 this.filePath,
269 `class __RazorCode__ {\n${block.content}\n}`,
270 'csharp'
271 ).extract();
272 } catch {
273 continue; // grammar not loaded / parse failure — skip this block
274 }
275 // The synthetic wrapper adds one line before the block content; map ref
276 // lines back to the .razor file (display only — coverage is line-agnostic).
277 for (const ref of result.unresolvedReferences) {
278 this.unresolvedReferences.push({
279 ...ref,
280 fromNodeId: componentId,
281 line: ref.line + block.lineOffset - 1,
282 column: ref.column,
283 filePath: this.filePath,
284 language: 'razor',
285 });
286 }
287 }
288 }
289
290 /**
291 * Hand each inline `<script>` to the JavaScript or TypeScript extractor and

Callers 1

extractMethod · 0.95

Calls 4

extractCodeBlocksMethod · 0.95
isLanguageSupportedFunction · 0.90
pushMethod · 0.80
extractMethod · 0.65

Tested by

no test coverage detected