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

Function declarationSourceWindow

src/resolution/frameworks/swift-objc.ts:157–164  ·  view source on GitHub ↗

* Read a small window of source ending at `node.startLine`, used to * inspect Swift attribute annotations attached to a declaration. Returns * an empty string if the source can't be read.

(node: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

155 * an empty string if the source can't be read.
156 */
157function declarationSourceWindow(node: Node, context: ResolutionContext): string {
158 const content = context.readFile(node.filePath);
159 if (!content) return '';
160 const lines = content.split(/\r?\n/);
161 const startIdx = Math.max(0, node.startLine - 1 - SOURCE_PROBE_LINES);
162 const endIdx = Math.min(lines.length, node.startLine);
163 return lines.slice(startIdx, endIdx).join('\n');
164}
165
166/**
167 * Try to resolve a Swift caller's bare reference to an ObjC implementation.

Callers 1

resolveObjcCallToSwiftFunction · 0.85

Calls 2

readFileMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected