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

Function readNodeSpanMatch

src/resolution/frameworks/terraform.ts:225–235  ·  view source on GitHub ↗

First capture of `re` across the node's line span, or null.

(node: Node, re: RegExp, context: ResolutionContext)

Source from the content-addressed store, hash-verified

223
224/** First capture of `re` across the node's line span, or null. */
225function readNodeSpanMatch(node: Node, re: RegExp, context: ResolutionContext): string | null {
226 const lines =
227 context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split('\n') ?? null;
228 if (!lines) return null;
229 const end = Math.min(node.endLine, lines.length);
230 for (let i = Math.max(node.startLine - 1, 0); i < end; i++) {
231 const m = lines[i]!.match(re);
232 if (m) return m[1]!;
233 }
234 return null;
235}
236
237/** Directory of a stored (forward-slash, project-relative) path. */
238function dirOf(p: string): string {

Callers 2

resolveScopedModuleRefFunction · 0.85
readModuleAttrFunction · 0.85

Calls 2

getFileLinesMethod · 0.80
readFileMethod · 0.80

Tested by

no test coverage detected