MCPcopy Index your code
hub / github.com/nodejs/node / getItemName

Function getItemName

test/fixtures/snapshot/typescript.js:141343–141386  ·  view source on GitHub ↗
(node, name)

Source from the content-addressed store, hash-verified

141341 }
141342 }
141343 function getItemName(node, name) {
141344 if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
141345 return cleanText(getModuleName(node));
141346 }
141347 if (name) {
141348 var text = ts.isIdentifier(name) ? name.text
141349 : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]")
141350 : nodeText(name);
141351 if (text.length > 0) {
141352 return cleanText(text);
141353 }
141354 }
141355 switch (node.kind) {
141356 case 305 /* SyntaxKind.SourceFile */:
141357 var sourceFile = node;
141358 return ts.isExternalModule(sourceFile)
141359 ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"")
141360 : "<global>";
141361 case 271 /* SyntaxKind.ExportAssignment */:
141362 return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */;
141363 case 214 /* SyntaxKind.ArrowFunction */:
141364 case 256 /* SyntaxKind.FunctionDeclaration */:
141365 case 213 /* SyntaxKind.FunctionExpression */:
141366 case 257 /* SyntaxKind.ClassDeclaration */:
141367 case 226 /* SyntaxKind.ClassExpression */:
141368 if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) {
141369 return "default";
141370 }
141371 // We may get a string with newlines or other whitespace in the case of an object dereference
141372 // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the
141373 // navigation bar.
141374 return getFunctionOrClassName(node);
141375 case 171 /* SyntaxKind.Constructor */:
141376 return "constructor";
141377 case 175 /* SyntaxKind.ConstructSignature */:
141378 return "new()";
141379 case 174 /* SyntaxKind.CallSignature */:
141380 return "()";
141381 case 176 /* SyntaxKind.IndexSignature */:
141382 return "[]";
141383 default:
141384 return "<unknown>";
141385 }
141386 }
141387 /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */
141388 function primaryNavBarMenuItems(root) {
141389 // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree.

Callers 3

convertToTreeFunction · 0.85

Calls 5

cleanTextFunction · 0.85
nodeTextFunction · 0.85
getFunctionOrClassNameFunction · 0.85
concatMethod · 0.80
getModuleNameFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…