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

Function classifySymbol

test/fixtures/snapshot/typescript.js:130424–130453  ·  view source on GitHub ↗
(symbol, meaningAtPosition, checker)

Source from the content-addressed store, hash-verified

130422 }
130423 ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications;
130424 function classifySymbol(symbol, meaningAtPosition, checker) {
130425 var flags = symbol.getFlags();
130426 if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) {
130427 return undefined;
130428 }
130429 else if (flags & 32 /* SymbolFlags.Class */) {
130430 return 11 /* ClassificationType.className */;
130431 }
130432 else if (flags & 384 /* SymbolFlags.Enum */) {
130433 return 12 /* ClassificationType.enumName */;
130434 }
130435 else if (flags & 524288 /* SymbolFlags.TypeAlias */) {
130436 return 16 /* ClassificationType.typeAliasName */;
130437 }
130438 else if (flags & 1536 /* SymbolFlags.Module */) {
130439 // Only classify a module as such if
130440 // - It appears in a namespace context.
130441 // - There exists a module declaration which actually impacts the value side.
130442 return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined;
130443 }
130444 else if (flags & 2097152 /* SymbolFlags.Alias */) {
130445 return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker);
130446 }
130447 else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) {
130448 return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined;
130449 }
130450 else {
130451 return undefined;
130452 }
130453 }
130454 /** Returns true if there exists a module that introduces entities on the value side. */
130455 function hasValueSideModule(symbol) {
130456 return ts.some(symbol.declarations, function (declaration) {

Callers 2

visitFunction · 0.85

Calls 3

hasValueSideModuleFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…