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

Function addChildrenRecursively

test/fixtures/snapshot/typescript.js:140889–141127  ·  view source on GitHub ↗

Look for navigation bar items in node's subtree, adding them to the current `parent`.

(node)

Source from the content-addressed store, hash-verified

140887 }
140888 /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */
140889 function addChildrenRecursively(node) {
140890 var _a;
140891 curCancellationToken.throwIfCancellationRequested();
140892 if (!node || ts.isToken(node)) {
140893 return;
140894 }
140895 switch (node.kind) {
140896 case 171 /* SyntaxKind.Constructor */:
140897 // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it.
140898 var ctr = node;
140899 addNodeWithRecursiveChild(ctr, ctr.body);
140900 // Parameter properties are children of the class, not the constructor.
140901 for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) {
140902 var param = _b[_i];
140903 if (ts.isParameterPropertyDeclaration(param, ctr)) {
140904 addLeafNode(param);
140905 }
140906 }
140907 break;
140908 case 169 /* SyntaxKind.MethodDeclaration */:
140909 case 172 /* SyntaxKind.GetAccessor */:
140910 case 173 /* SyntaxKind.SetAccessor */:
140911 case 168 /* SyntaxKind.MethodSignature */:
140912 if (hasNavigationBarName(node)) {
140913 addNodeWithRecursiveChild(node, node.body);
140914 }
140915 break;
140916 case 167 /* SyntaxKind.PropertyDeclaration */:
140917 if (hasNavigationBarName(node)) {
140918 addNodeWithRecursiveInitializer(node);
140919 }
140920 break;
140921 case 166 /* SyntaxKind.PropertySignature */:
140922 if (hasNavigationBarName(node)) {
140923 addLeafNode(node);
140924 }
140925 break;
140926 case 267 /* SyntaxKind.ImportClause */:
140927 var importClause = node;
140928 // Handle default import case e.g.:
140929 // import d from "mod";
140930 if (importClause.name) {
140931 addLeafNode(importClause.name);
140932 }
140933 // Handle named bindings in imports e.g.:
140934 // import * as NS from "mod";
140935 // import {a, b as B} from "mod";
140936 var namedBindings = importClause.namedBindings;
140937 if (namedBindings) {
140938 if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
140939 addLeafNode(namedBindings);
140940 }
140941 else {
140942 for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) {
140943 var element = _d[_c];
140944 addLeafNode(element);
140945 }
140946 }

Callers 2

rootNavigationBarNodeFunction · 0.85

Calls 14

addLeafNodeFunction · 0.85
hasNavigationBarNameFunction · 0.85
addTrackedEs5ClassFunction · 0.85
startNodeFunction · 0.85
isComputedPropertyFunction · 0.85
endNodeFunction · 0.85
getInteriorModuleFunction · 0.85
startNestedNodesFunction · 0.85
endNestedNodesFunction · 0.85
forEachChildMethod · 0.80

Tested by

no test coverage detected