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

Function declarationText

src/resolution/frameworks/react.ts:833–840  ·  view source on GitHub ↗
(node: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

831
832/** A declarator's own source text: `B = lazy(…)` in `const A = lazy(…), B = lazy(…)`. */
833export function declarationText(node: Node, context: ResolutionContext): string {
834 const lines = (context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split(/\r?\n/) ?? [])
835 .slice(node.startLine - 1, node.endLine);
836 if (lines.length === 0) return '';
837 if (node.endColumn > 0) lines[lines.length - 1] = lines[lines.length - 1]!.slice(0, node.endColumn);
838 lines[0] = lines[0]!.slice(node.startColumn);
839 return lines.join('\n');
840}
841
842/**
843 * The component a value wraps, which is what it renders: the function it

Callers 5

initializerOfFunction · 0.90
valueLoaderFunction · 0.70
heldBindingFunction · 0.70
handedComponentFunction · 0.70
wrappedComponentNameFunction · 0.70

Calls 3

getFileLinesMethod · 0.80
readFileMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected