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

Function isDeclarationVisible

test/fixtures/snapshot/typescript.js:55479–55573  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

55477 return name !== undefined ? name : ts.symbolName(symbol);
55478 }
55479 function isDeclarationVisible(node) {
55480 if (node) {
55481 var links = getNodeLinks(node);
55482 if (links.isVisible === undefined) {
55483 links.isVisible = !!determineIfDeclarationIsVisible();
55484 }
55485 return links.isVisible;
55486 }
55487 return false;
55488 function determineIfDeclarationIsVisible() {
55489 switch (node.kind) {
55490 case 338 /* SyntaxKind.JSDocCallbackTag */:
55491 case 345 /* SyntaxKind.JSDocTypedefTag */:
55492 case 339 /* SyntaxKind.JSDocEnumTag */:
55493 // Top-level jsdoc type aliases are considered exported
55494 // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
55495 return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
55496 case 203 /* SyntaxKind.BindingElement */:
55497 return isDeclarationVisible(node.parent.parent);
55498 case 254 /* SyntaxKind.VariableDeclaration */:
55499 if (ts.isBindingPattern(node.name) &&
55500 !node.name.elements.length) {
55501 // If the binding pattern is empty, this variable declaration is not visible
55502 return false;
55503 }
55504 // falls through
55505 case 261 /* SyntaxKind.ModuleDeclaration */:
55506 case 257 /* SyntaxKind.ClassDeclaration */:
55507 case 258 /* SyntaxKind.InterfaceDeclaration */:
55508 case 259 /* SyntaxKind.TypeAliasDeclaration */:
55509 case 256 /* SyntaxKind.FunctionDeclaration */:
55510 case 260 /* SyntaxKind.EnumDeclaration */:
55511 case 265 /* SyntaxKind.ImportEqualsDeclaration */:
55512 // external module augmentation is always visible
55513 if (ts.isExternalModuleAugmentation(node)) {
55514 return true;
55515 }
55516 var parent = getDeclarationContainer(node);
55517 // If the node is not exported or it is not ambient module element (except import declaration)
55518 if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) &&
55519 !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) {
55520 return isGlobalSourceFile(parent);
55521 }
55522 // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
55523 return isDeclarationVisible(parent);
55524 case 167 /* SyntaxKind.PropertyDeclaration */:
55525 case 166 /* SyntaxKind.PropertySignature */:
55526 case 172 /* SyntaxKind.GetAccessor */:
55527 case 173 /* SyntaxKind.SetAccessor */:
55528 case 169 /* SyntaxKind.MethodDeclaration */:
55529 case 168 /* SyntaxKind.MethodSignature */:
55530 if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
55531 // Private/protected properties/methods are not visible
55532 return false;
55533 }
55534 // Public properties/methods are visible if its parents are visible, so:
55535 // falls through
55536 case 171 /* SyntaxKind.Constructor */:

Callers 2

getIsDeclarationVisibleFunction · 0.85

Calls 2

getNodeLinksFunction · 0.85

Tested by

no test coverage detected