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

Function tryGetName

test/fixtures/snapshot/typescript.js:141325–141342  ·  view source on GitHub ↗

* This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. * So `new()` can still come before an `aardvark` method.

(node)

Source from the content-addressed store, hash-verified

141323 * So `new()` can still come before an `aardvark` method.
141324 */
141325 function tryGetName(node) {
141326 if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
141327 return getModuleName(node);
141328 }
141329 var declName = ts.getNameOfDeclaration(node);
141330 if (declName && ts.isPropertyName(declName)) {
141331 var propertyName = ts.getPropertyNameForPropertyNameNode(declName);
141332 return propertyName && ts.unescapeLeadingUnderscores(propertyName);
141333 }
141334 switch (node.kind) {
141335 case 213 /* SyntaxKind.FunctionExpression */:
141336 case 214 /* SyntaxKind.ArrowFunction */:
141337 case 226 /* SyntaxKind.ClassExpression */:
141338 return getFunctionOrClassName(node);
141339 default:
141340 return undefined;
141341 }
141342 }
141343 function getItemName(node, name) {
141344 if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
141345 return cleanText(getModuleName(node));

Callers 1

compareChildrenFunction · 0.85

Calls 2

getFunctionOrClassNameFunction · 0.85
getModuleNameFunction · 0.70

Tested by

no test coverage detected