MCPcopy
hub / github.com/colbymchenry/codegraph / resolveStaticMember

Function resolveStaticMember

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

* Resolve `Container.member` — a static method/property access on a NAMED class * import (`import { Foo } …; Foo.bar()`) — to the member node, given the * already-resolved container class. * * Members carry a `Container::member` qualifiedName, so we look up * `${container.qualifiedName}::${memb

(
  container: Node,
  ref: UnresolvedRef,
  localName: string,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

1935 * are unaffected. See #825.
1936 */
1937function resolveStaticMember(
1938 container: Node,
1939 ref: UnresolvedRef,
1940 localName: string,
1941 context: ResolutionContext
1942): Node | undefined {
1943 if (!STATIC_MEMBER_CONTAINERS.has(container.kind)) return undefined;
1944 // First segment after the receiver: `Foo.bar.baz` → `bar`.
1945 const member = ref.referenceName.slice(localName.length + 1).split('.')[0];
1946 if (!member) return undefined;
1947
1948 const candidates = context
1949 .getNodesByQualifiedName(`${container.qualifiedName}::${member}`)
1950 .filter((n) => n.filePath === container.filePath);
1951 if (candidates.length === 0) return undefined;
1952
1953 // When the reference is a call, prefer a callable member if several nodes
1954 // share the qualifiedName (e.g. a static property and a method).
1955 if (ref.referenceKind === 'calls') {
1956 const callable = candidates.find((n) => n.kind === 'method' || n.kind === 'function');
1957 if (callable) return callable;
1958 }
1959 return candidates[0];
1960}

Callers 1

resolveViaImportFunction · 0.85

Calls 2

hasMethod · 0.80

Tested by

no test coverage detected