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

Function typeMemberIn

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

* What `path` names in `file`, from the namespace `scope` (the file's top * level when empty): a namespace takes the next name as a member of its own, * and an enum, a class or an interface takes the rest as its `::` members.

(file: string, scope: string[], path: string[], context: ResolutionContext)

Source from the content-addressed store, hash-verified

3202 * and an enum, a class or an interface takes the rest as its `::` members.
3203 */
3204function typeMemberIn(file: string, scope: string[], path: string[], context: ResolutionContext): Node | undefined {
3205 const [name, ...rest] = path;
3206 if (name === undefined) return undefined;
3207 if (rest.length > 0 && hasNamespace(file, [...scope, name].join('.'), context)) {
3208 return typeMemberIn(file, [...scope, name], rest, context);
3209 }
3210 const declared = declarationsIn(file, scope, name, context);
3211 if (rest.length === 0) return declared[0];
3212 const container = declared.find((n) => STATIC_MEMBER_CONTAINERS.has(n.kind));
3213 return container ? containerMember(container, rest, context) : undefined;
3214}
3215
3216/** An enum's, a class's or an interface's member at `path` (`Kind::Line`), in the container's own file. */
3217function containerMember(container: Node, path: string[], context: ResolutionContext): Node | undefined {

Callers 3

importedTypeMemberFunction · 0.85
ownTypeMemberFunction · 0.85
resolveViaImportFunction · 0.85

Calls 5

hasNamespaceFunction · 0.85
declarationsInFunction · 0.85
containerMemberFunction · 0.85
hasMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected