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

Function localTypeBinding

src/resolution/import-resolver.ts:5021–5029  ·  view source on GitHub ↗

* The import binding of the type a call's receiver is declared with, read the * way resolution reads it for the call (inferLocalReceiverType, memoized per * file, scope and receiver, so a call the matcher just tried costs a lookup): * the binding the type is written through, `LRUCache` of `new LR

(receiver: string, ref: UnresolvedRef, context: ResolutionContext, mappings: ImportMapping[])

Source from the content-addressed store, hash-verified

5019 * nearly doubled what an edit of `uri.ts` retried.
5020 */
5021function localTypeBinding(receiver: string, ref: UnresolvedRef, context: ResolutionContext, mappings: ImportMapping[]): ImportMapping | undefined {
5022 if (mappings.length === 0) return undefined;
5023 const decl: { raw?: string } = {};
5024 const type = inferLocalReceiverType(receiver, ref, context, decl);
5025 if (!type || !decl.raw) return undefined;
5026 if (arrayElementType(type) !== undefined && JS_ARRAY_METHODS.has(ref.referenceName.slice(receiver.length + 1))) return undefined;
5027 const head = decl.raw.split(/[.<[\s]/)[0];
5028 return mappings.find((m) => m.localName === head);
5029}
5030
5031/**
5032 * The declaration a default import of `filePath` written in `language` binds

Callers 1

importBindingTailFunction · 0.85

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected