(
resolved: ResolvedRef | null,
ref: { language: string },
context: ResolutionContext,
)
| 37 | * `@overload` stub that has one below it in its scope. |
| 38 | */ |
| 39 | export 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. */ |
| 57 | function implementationOf(def: Node, context: ResolutionContext): string | null { |
no test coverage detected