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

Function bind

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

Source from the content-addressed store, hash-verified

46726 }
46727 }
46728 function bind(node) {
46729 if (!node) {
46730 return;
46731 }
46732 ts.setParent(node, parent);
46733 if (ts.tracing)
46734 node.tracingPath = file.path;
46735 var saveInStrictMode = inStrictMode;
46736 // Even though in the AST the jsdoc @typedef node belongs to the current node,
46737 // its symbol might be in the same scope with the current node's symbol. Consider:
46738 //
46739 // /** @typedef {string | number} MyType */
46740 // function foo();
46741 //
46742 // Here the current node is "foo", which is a container, but the scope of "MyType" should
46743 // not be inside "foo". Therefore we always bind @typedef before bind the parent node,
46744 // and skip binding this tag later when binding all the other jsdoc tags.
46745 // First we bind declaration nodes to a symbol if possible. We'll both create a symbol
46746 // and then potentially add the symbol to an appropriate symbol table. Possible
46747 // destination symbol tables are:
46748 //
46749 // 1) The 'exports' table of the current container's symbol.
46750 // 2) The 'members' table of the current container's symbol.
46751 // 3) The 'locals' table of the current container.
46752 //
46753 // However, not all symbols will end up in any of these tables. 'Anonymous' symbols
46754 // (like TypeLiterals for example) will not be put in any table.
46755 bindWorker(node);
46756 // Then we recurse into the children of the node to bind them as well. For certain
46757 // symbols we do specialized work when we recurse. For example, we'll keep track of
46758 // the current 'container' node when it changes. This helps us know which symbol table
46759 // a local should go into for example. Since terminal nodes are known not to have
46760 // children, as an optimization we don't process those.
46761 if (node.kind > 160 /* SyntaxKind.LastToken */) {
46762 var saveParent = parent;
46763 parent = node;
46764 var containerFlags = getContainerFlags(node);
46765 if (containerFlags === 0 /* ContainerFlags.None */) {
46766 bindChildren(node);
46767 }
46768 else {
46769 bindContainer(node, containerFlags);
46770 }
46771 parent = saveParent;
46772 }
46773 else {
46774 var saveParent = parent;
46775 if (node.kind === 1 /* SyntaxKind.EndOfFileToken */)
46776 parent = node;
46777 bindJSDoc(node);
46778 parent = saveParent;
46779 }
46780 inStrictMode = saveInStrictMode;
46781 }
46782 function bindJSDoc(node) {
46783 if (ts.hasJSDocNodes(node)) {
46784 if (ts.isInJSFile(node)) {

Callers 15

bindSourceFileFunction · 0.70
bindEachFunctionsFirstFunction · 0.70
bindChildrenFunction · 0.70
bindIterativeStatementFunction · 0.70
bindForStatementFunction · 0.70
bindIfStatementFunction · 0.70
bindReturnOrThrowFunction · 0.70
bindTryStatementFunction · 0.70
bindSwitchStatementFunction · 0.70
bindCaseBlockFunction · 0.70

Calls 5

bindWorkerFunction · 0.85
getContainerFlagsFunction · 0.85
bindChildrenFunction · 0.85
bindContainerFunction · 0.85
bindJSDocFunction · 0.85

Tested by

no test coverage detected