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

Function preferPythonImplementation

src/resolution/python-overloads.ts:39–54  ·  view source on GitHub ↗
(
  resolved: ResolvedRef | null,
  ref: { language: string },
  context: ResolutionContext,
)

Source from the content-addressed store, hash-verified

37 * `@overload` stub that has one below it in its scope.
38 */
39export function preferPythonImplementation(
40 resolved: ResolvedRef | null,
41 ref: { language: string },
42 context: ResolutionContext,
43): ResolvedRef | null {
44 if (!resolved || ref.language !== 'python') return resolved;
45 let memo = RUNS_INSTEAD.get(context);
46 if (!memo) RUNS_INSTEAD.set(context, (memo = new Map()));
47 let runs = memo.get(resolved.targetNodeId);
48 if (runs === undefined) {
49 const target = context.getNodeById?.(resolved.targetNodeId) ?? null;
50 runs = target ? implementationOf(target, context) : null;
51 memo.set(resolved.targetNodeId, runs);
52 }
53 return runs === null ? resolved : { ...resolved, targetNodeId: runs };
54}
55
56/** The implementation a stub stands for: the first `def` of its scope and name below it that is no stub. */
57function implementationOf(def: Node, context: ResolutionContext): string | null {

Callers 1

resolveOneInMethod · 0.90

Calls 4

implementationOfFunction · 0.85
getMethod · 0.65
getNodeByIdMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected