MCPcopy Create free account
hub / github.com/nodejs/node / getTopMostDeclarationNamesInFile

Function getTopMostDeclarationNamesInFile

test/fixtures/snapshot/typescript.js:138004–138026  ·  view source on GitHub ↗
(declarationName, sourceFile)

Source from the content-addressed store, hash-verified

138002 }
138003 Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
138004 function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
138005 var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
138006 return candidates.reduce(function (topMost, decl) {
138007 var depth = getDepth(decl);
138008 if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
138009 topMost.declarationNames.push(decl);
138010 topMost.depth = depth;
138011 }
138012 else if (depth < topMost.depth) {
138013 topMost.declarationNames = [decl];
138014 topMost.depth = depth;
138015 }
138016 return topMost;
138017 }, { depth: Infinity, declarationNames: [] }).declarationNames;
138018 function getDepth(declaration) {
138019 var depth = 0;
138020 while (declaration) {
138021 declaration = ts.getContainerNode(declaration);
138022 depth++;
138023 }
138024 return depth;
138025 }
138026 }
138027 Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
138028 function someSignatureUsage(signature, sourceFiles, checker, cb) {
138029 if (!signature.name || !ts.isIdentifier(signature.name))

Callers

nothing calls this directly

Calls 6

getDepthFunction · 0.85
reduceMethod · 0.80
someMethod · 0.80
filterMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected