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

Function declarationsIn

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

The declarations named `name` directly in the namespace `scope` of `file` (its top level when empty), types first.

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

Source from the content-addressed store, hash-verified

3236
3237/** The declarations named `name` directly in the namespace `scope` of `file` (its top level when empty), types first. */
3238function declarationsIn(file: string, scope: string[], name: string, context: ResolutionContext): Node[] {
3239 const blocks = namespaceBlocks(file, context);
3240 const want = scope.join('.');
3241 return (context.getNodesInFileNamed?.(file, name) ?? context.getNodesInFile(file).filter((n) => n.name === name))
3242 .filter((n) => n.qualifiedName === name && MEMBER_DECLARATION_KINDS.has(n.kind) && (innermostBlock(n, blocks)?.path ?? '') === want)
3243 .sort(typesFirst);
3244}
3245
3246/** Whether `file` declares the namespace `path`, itself or as the prefix of a longer one (`namespace A.B` declares `A`). */
3247function hasNamespace(file: string, path: string, context: ResolutionContext): boolean {

Callers 2

ownTypeMemberFunction · 0.85
typeMemberInFunction · 0.85

Calls 6

namespaceBlocksFunction · 0.90
innermostBlockFunction · 0.85
getNodesInFileNamedMethod · 0.80
hasMethod · 0.80
getNodesInFileMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected