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

Function localTypeBinding

src/resolution/import-resolver.ts:4799–4807  ·  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

4797 * nearly doubled what an edit of `uri.ts` retried.
4798 */
4799function localTypeBinding(receiver: string, ref: UnresolvedRef, context: ResolutionContext, mappings: ImportMapping[]): ImportMapping | undefined {
4800 if (mappings.length === 0) return undefined;
4801 const decl: { raw?: string } = {};
4802 const type = inferLocalReceiverType(receiver, ref, context, decl);
4803 if (!type || !decl.raw) return undefined;
4804 if (arrayElementType(type) !== undefined && JS_ARRAY_METHODS.has(ref.referenceName.slice(receiver.length + 1))) return undefined;
4805 const head = decl.raw.split(/[.<[\s]/)[0];
4806 return mappings.find((m) => m.localName === head);
4807}
4808
4809/**
4810 * 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