Debian Codegraph @

packages/babel-traverse/src/scope/index.ts

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 import Renamerscip-typescript npm @babel/traverse 7.20.13 src/scope/lib/`renamer.ts`/Renamer# from "./lib/renamer"scip-typescript npm @babel/traverse 7.20.13 src/scope/lib/`renamer.ts`/;
2 import type NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# from "../path"scip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/;
3 import traversescip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/traverse(). from "../index"scip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/;
4 import type { TraverseOptionsscip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/TraverseOptions# } from "../index"scip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/;
5 import Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# from "./binding"scip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/;
6 import type { BindingKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/BindingKind# } from "./binding"scip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/;
7 import globals from "globals";
8 import {
9 NOT_LOCAL_BINDINGscip-typescript npm @babel/types 7.20.7 src/constants/`index.ts`/NOT_LOCAL_BINDING.,
10 callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().,
11 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().,
12 getBindingIdentifiersscip-typescript npm @babel/types 7.20.7 src/retrievers/`getBindingIdentifiers.ts`/getBindingIdentifiers().,
13 identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().,
14 isArrayExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isArrayExpression().,
15 isBinaryscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isBinary().,
16 isClassscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClass().,
17 isClassBodyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClassBody().,
18 isClassDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClassDeclaration().,
19 isExportAllDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportAllDeclaration().,
20 isExportDefaultDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportDefaultDeclaration().,
21 isExportNamedDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportNamedDeclaration().,
22 isFunctionDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isFunctionDeclaration().,
23 isIdentifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isIdentifier().,
24 isImportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isImportDeclaration().,
25 isLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isLiteral().,
26 isMethodscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMethod().,
27 isModuleSpecifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isModuleSpecifier().,
28 isNullLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isNullLiteral().,
29 isObjectExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isObjectExpression().,
30 isPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isProperty().,
31 isPureishscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isPureish().,
32 isRegExpLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isRegExpLiteral().,
33 isSuperscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isSuper().,
34 isTaggedTemplateExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTaggedTemplateExpression().,
35 isTemplateLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTemplateLiteral().,
36 isThisExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isThisExpression().,
37 isUnaryExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isUnaryExpression().,
38 isVariableDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isVariableDeclaration().,
39 matchesPatternscip-typescript npm @babel/types 7.20.7 src/validators/`matchesPattern.ts`/matchesPattern().,
40 memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().,
41 numericLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/numericLiteral().,
42 toIdentifierscip-typescript npm @babel/types 7.20.7 src/converters/`toIdentifier.ts`/toIdentifier().,
43 unaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/unaryExpression().,
44 variableDeclarationscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclaration().,
45 variableDeclaratorscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclarator().,
46 isRecordExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isRecordExpression().,
47 isTupleExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTupleExpression().,
48 isObjectPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isObjectProperty().,
49 isTopicReferencescip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTopicReference().,
50 isMetaPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMetaProperty().,
51 isPrivateNamescip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isPrivateName().,
52 isExportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportDeclaration().,
53 } from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/;
54 import type * as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/ from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/;
55 import { scopescip-typescript npm @babel/traverse 7.20.13 src/`cache.ts`/scope. as scopeCachescip-typescript npm @babel/traverse 7.20.13 src/`cache.ts`/scope. } from "../cache"scip-typescript npm @babel/traverse 7.20.13 src/`cache.ts`/;
56 import type { Visitorscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/Visitor# } from "../types"scip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/;
57
58 type NodePartscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/NodePart# = string | number | boolean;
59 // Recursively gathers the identifying names of a node.
60 function gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts): NodePartscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/NodePart#[]) {
61 switch (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)?.typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.) {
62 default:
63 if (isImportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isImportDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) || isExportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))) {
64 if (
65 (isExportAllDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportAllDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) ||
66 isExportNamedDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportNamedDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) ||
67 isImportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isImportDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))) &&
68 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).sourcescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportAllDeclaration#source.
69 ) {
70 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).sourcescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportAllDeclaration#source., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
71 } else if (
72 (isExportNamedDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportNamedDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) || isImportDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isImportDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))) &&
73 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).specifiersscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportNamedDeclaration#specifiers. &&
74 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).specifiersscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportNamedDeclaration#specifiers..lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length.
75 ) {
76 for (const e of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).specifiersscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportNamedDeclaration#specifiers.) gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(e, partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
77 } else if (
78 (isExportDefaultDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportDefaultDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) ||
79 isExportNamedDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportNamedDeclaration().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))) &&
80 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).declarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportDefaultDeclaration#declaration.
81 ) {
82 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).declarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportDefaultDeclaration#declaration., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
83 }
84 } else if (isModuleSpecifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isModuleSpecifier().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))) {
85 // todo(flow->ts): should condition instead be:
86 // ```
87 // t.isExportSpecifier(node) ||
88 // t.isImportDefaultSpecifier(node) ||
89 // t.isImportNamespaceSpecifier(node) ||
90 // t.isImportSpecifier(node)
91 // ```
92 // allowing only nodes with `.local`?
93 // @ts-expect-error todo(flow->ts)
94 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).local, partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
95 } else if (
96 isLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isLiteral().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) &&
97 !isNullLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isNullLiteral().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) &&
98 !isRegExpLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isRegExpLiteral().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node)) &&
99 !isTemplateLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTemplateLiteral().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node))
100 ) {
101 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).valuescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BigIntLiteral#value.);
102 }
103 break;
104
105 case "MemberExpression":
106 case "OptionalMemberExpression":
107 case "JSXMemberExpression":
108 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).objectscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXMemberExpression#object., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
109 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).propertyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXMemberExpression#property., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
110 break;
111
112 case "Identifier":
113 case "JSXIdentifier":
114 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
115 break;
116
117 case "CallExpression":
118 case "OptionalCallExpression":
119 case "NewExpression":
120 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).calleescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/CallExpression#callee., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
121 break;
122
123 case "ObjectExpression":
124 case "ObjectPattern":
125 for (const e of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).propertiesscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ObjectExpression#properties.) {
126 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(e, partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
127 }
128 break;
129
130 case "SpreadElement":
131 case "RestElement":
132 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).argumentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/RestElement#argument., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
133 break;
134
135 case "ObjectProperty":
136 case "ObjectMethod":
137 case "ClassProperty":
138 case "ClassMethod":
139 case "ClassPrivateProperty":
140 case "ClassPrivateMethod":
141 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).keyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassMethod#key., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
142 break;
143
144 case "ThisExpression":
145 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("this");
146 break;
147
148 case "Super":
149 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("super");
150 break;
151
152 case "Import":
153 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("import");
154 break;
155
156 case "DoExpression":
157 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("do");
158 break;
159
160 case "YieldExpression":
161 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("yield");
162 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).argumentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/YieldExpression#argument., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
163 break;
164
165 case "AwaitExpression":
166 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("await");
167 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).argumentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/AwaitExpression#argument., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
168 break;
169
170 case "AssignmentExpression":
171 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).leftscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/AssignmentExpression#left., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
172 break;
173
174 case "VariableDeclarator":
175 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclarator#id., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
176 break;
177
178 case "FunctionExpression":
179 case "FunctionDeclaration":
180 case "ClassExpression":
181 case "ClassDeclaration":
182 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#id., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
183 break;
184
185 case "PrivateName":
186 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/PrivateName#id., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
187 break;
188
189 case "ParenthesizedExpression":
190 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ParenthesizedExpression#expression., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
191 break;
192
193 case "UnaryExpression":
194 case "UpdateExpression":
195 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).argumentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/UnaryExpression#argument., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
196 break;
197
198 case "MetaProperty":
199 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).metascip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/MetaProperty#meta., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
200 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).propertyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/MetaProperty#property., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
201 break;
202
203 case "JSXElement":
204 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).openingElementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXElement#openingElement., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
205 break;
206
207 case "JSXOpeningElement":
208 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXOpeningElement#name., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
209 break;
210
211 case "JSXFragment":
212 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).openingFragmentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXFragment#openingFragment., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
213 break;
214
215 case "JSXOpeningFragment":
216 partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts).pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("Fragment");
217 break;
218
219 case "JSXNamespacedName":
220 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).namespacescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXNamespacedName#namespace., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
221 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXNamespacedName#name., partsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(parts));
222 break;
223 }
224 }
225
226 //
227 interface CollectVisitorStatescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState# {
228 assignmentsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#assignments.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.AssignmentExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/AssignmentExpression#>[];
229 referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#references.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.JSXIdentifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXIdentifier#>[];
230 constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#[];
231 }
232
233 const collectorVisitorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/collectorVisitor.: Visitorscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/Visitor#<CollectVisitorStatescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#> = {
234 ForStatement(path) {
235 const declar = path.get("init");
236 // delegate block scope handling to the `BlockScoped` method
237 if (declar.isVarscip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types-validator.ts`/VirtualTypeNodePathValidators#isVar().()) {
238 const { scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
239 const parentScope = scope.getFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getFunctionParent().() || scope.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
240 parentScope.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("var", declar);
241 }
242 },
243
244 Declarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Aliases#Declaration.(path) {
245 // delegate block scope handling to the `BlockScoped` method
246 if (path.isBlockScopedscip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types-validator.ts`/VirtualTypeNodePathValidators#isBlockScoped().()) return;
247
248 // delegate import handing to the `ImportDeclaration` method
•249 // @ts-ignore
250 if (path.isImportDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isImportDeclaration().()) return;
251
252 // this will be hit again once we traverse into it after this iteration
•253 // @ts-ignore
254 if (path.isExportDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isExportDeclaration().()) return;
255
256 // we've ran into a declaration!
257 const parent =
•258 // @ts-ignore
259 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getFunctionParent().() || path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
260 parent.registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path);
261 },
262
263 ImportDeclaration(path) {
264 // import may only appear in the top level or inside a module/namespace (for TS/flow)
265 const parent = path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().();
266
267 parent.registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path);
268 },
269
270 ReferencedIdentifierscip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types.ts`/VirtualTypeAliases#ReferencedIdentifier.(path, state) {
271 state.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#references..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(path);
272 },
273
274 ForXStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Aliases#ForXStatement.(path, state) {
275 const left = path.get("left");
276 if (left.isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().() || left.isIdentifierscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isIdentifier().()) {
277 state.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(path);
278 }
279 // delegate block scope handling to the `BlockScoped` method
280 else if (left.isVarscip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types-validator.ts`/VirtualTypeNodePathValidators#isVar().()) {
281 const { scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
282 const parentScope = scope.getFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getFunctionParent().() || scope.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
283 parentScope.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("var", left);
284 }
285 },
286
287 ExportDeclarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Aliases#ExportDeclaration.: {
288 exit(path) {
289 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
290 // ExportAllDeclaration does not have `declaration`
291 if (isExportAllDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isExportAllDeclaration().(node)) return;
292 const declar = node.declarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ExportDefaultDeclaration#declaration.;
293 if (isClassDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClassDeclaration().(declar) || isFunctionDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isFunctionDeclaration().(declar)) {
294 const id = declar.idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#id.;
295 if (!id) return;
296
297 const binding = scope.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(id.namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
298 binding?.referencescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(path);
299 } else if (isVariableDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isVariableDeclaration().(declar)) {
300 for (const decl of declar.declarationsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#declarations.) {
301 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(getBindingIdentifiersscip-typescript npm @babel/types 7.20.7 src/retrievers/`getBindingIdentifiers.ts`/getBindingIdentifiers().(decl))) {
302 const binding = scope.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name);
303 binding?.referencescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(path);
304 }
305 }
306 }
307 },
308 },
309
310 LabeledStatement(path) {
311 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().().registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path);
312 },
313
314 AssignmentExpression(path, state) {
315 state.assignmentsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#assignments..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(path);
316 },
317
318 UpdateExpression(path, state) {
319 state.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(path);
320 },
321
322 UnaryExpression(path, state) {
323 if (path.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..operatorscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/UnaryExpression#operator. === "delete") {
324 state.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(path);
325 }
326 },
327
328 BlockScopedscip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types.ts`/VirtualTypeAliases#BlockScoped.(path) {
329 let scope = path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope.;
330 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path. === path) scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().;
331
332 const parent = scope.getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().();
333 parent.registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path);
334
335 // Register class identifier in class' scope if this is a class declaration.
336 if (path.isClassDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isClassDeclaration().() && path.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#id.) {
337 const id = path.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#id.;
338 const name = id.namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.;
339
340 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[name] = path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`()..getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name);
341 }
342 },
343
344 CatchClause(path) {
345 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("let", path);
346 },
347
348 Functionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Aliases#Function.(path) {
349 const params: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#> = path.get("params");
350 for (const param of params) {
351 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("param", param);
352 }
353
354 // Register function expression id after params. When the id
355 // collides with a function param, the id effectively can't be
356 // referenced: here we registered it as a constantViolation
357 if (
358 path.isFunctionExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunctionExpression().() &&
359 path.hasscip-typescript npm @babel/traverse 7.20.13 src/path/`introspection.ts`/has().("id") &&
360 // @ts-expect-error Fixme: document symbol ast properties
361 !path.get("id").nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.[NOT_LOCAL_BINDINGscip-typescript npm @babel/types 7.20.7 src/constants/`index.ts`/NOT_LOCAL_BINDING.]
362 ) {
363 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("local", path.get("id"), path);
364 }
365 },
366
367 ClassExpression(path) {
368 if (
369 path.hasscip-typescript npm @babel/traverse 7.20.13 src/path/`introspection.ts`/has().("id") &&
370 // @ts-expect-error Fixme: document symbol ast properties
371 !path.get("id").nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.[NOT_LOCAL_BINDINGscip-typescript npm @babel/types 7.20.7 src/constants/`index.ts`/NOT_LOCAL_BINDING.]
372 ) {
373 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("local", path);
374 }
375 },
376 };
377
378 let uidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/uid. = 0;
379
380 export type { Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# };
381
382 export default class Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# {
383 uidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uid.;
384
385 pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#;
386 blockscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#block.: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Patternscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Pattern# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Scopablescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Scopable#;
387
388 labelsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#labels.;
389 initedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#inited.;
390
391 bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.: { [name: string]: Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# };
392 referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#references.: { [name: string]: true };
393 globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals.: { [name: string]: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.JSXIdentifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXIdentifier# };
394 uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids.: { [name: string]: boolean };
395 datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data.: { [key: string | symbol]: unknown };
396 crawlingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawling.: boolean;
397
398 /**
399 * This searches the current "scope" and collects all references/bindings
400 * within.
401 */
402 constructorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<constructor>`().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<constructor>`().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Patternscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Pattern# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Scopablescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Scopable#>) {
403 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. } = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<constructor>`().(path);
404 const cached = scopeCachescip-typescript npm @babel/traverse 7.20.13 src/`cache.ts`/scope..getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#get().(node);
405 // Sometimes, a scopable path is placed higher in the AST tree.
406 // In these cases, have to create a new Scope.
407 if (cached?.path === pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<constructor>`().(path)) {
408 return cached;
409 }
410 scopeCachescip-typescript npm @babel/traverse 7.20.13 src/`cache.ts`/scope..setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#set().(node, this);
411
412 this.uidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uid. = uidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/uid.++;
413
414 this.blockscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#block. = node;
415 this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path. = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<constructor>`().(path);
416
417 this.labelsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#labels. = new Mapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#();
418 this.initedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#inited. = false;
419 }
420
421 /**
422 * Globals.
423 */
424
425 static globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(globals.builtin);
426
427 /**
428 * Variables available in current context.
429 */
430
431 static contextVariablesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#contextVariables. = ["arguments", "undefined", "Infinity", "NaN"];
432
433 get parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().() {
434 let parent,
435 path = this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
436 do {
437 // Skip method scope if coming from inside computed key or decorator expression
438 const shouldSkip = path.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. === "key" || path.listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#listKey. === "decorators";
439 path = path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.;
440 if (shouldSkip && path.isMethodscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isMethod().()) path = path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.;
441 if (path && path.isScopescip-typescript npm @babel/traverse 7.20.13 src/path/lib/`virtual-types-validator.ts`/VirtualTypeNodePathValidators#isScope().()) parent = path;
442 } while (path && !parent);
443
444 return parent?.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope.;
445 }
446
447 get parentBlockscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parentBlock`().() {
448 return this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent.;
449 }
450
451 get hubscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>hub`().() {
452 return this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..hubscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#hub.;
453 }
454
455 traversescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().<Sscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().[S]>(
456 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#[],
457 optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(opts): TraverseOptionsscip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/TraverseOptions#<Sscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().[S]>,
458 statescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(state): Sscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().[S],
459 ): void;
460 traversescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#[], optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(opts)?: TraverseOptionsscip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/TraverseOptions#, statescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(state)?: any): void;
461 /**
462 * Traverse node with current scope and path.
463 *
464 * !!! WARNING !!!
465 * This method assumes that `this.path` is the NodePath representing `node`.
466 * After running the traversal, the `.parentPath` of the NodePaths
467 * corresponding to `node`'s children will be set to `this.path`.
468 *
469 * There is no good reason to use this method, since the only safe way to use
470 * it is equivalent to `scope.path.traverse(opts, state)`.
471 */
472 traversescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().<Sscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().[S]>(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(node): any, optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(opts): any, statescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(state)?: Sscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().[S]) {
473 traversescip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/traverse().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(node), optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(opts), this, statescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#traverse().(state), this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.);
474 }
475
476 /**
477 * Generate a unique identifier and add it to the current scope.
478 */
479
480 generateDeclaredUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateDeclaredUidIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateDeclaredUidIdentifier().(name)?: string) {
481 const id = this.generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateDeclaredUidIdentifier().(name));
482 this.pushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().({ idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id. });
483 return cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(id);
484 }
485
486 /**
487 * Generate a unique identifier.
488 */
489
490 generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().(name)?: string) {
491 return identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().(this.generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().(name)));
492 }
493
494 /**
495 * Generate a unique `_id1` binding.
496 */
497
498 generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(name): string = "temp"): string {
499 namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(name) = toIdentifierscip-typescript npm @babel/types 7.20.7 src/converters/`toIdentifier.ts`/toIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(name))
500 .replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/^_+/, "")
501 .replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/[0-9]+$/g, "");
502
503 let uid;
504 let i = 1;
505 do {
506 uid = this._generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(name), i);
507 i++;
508 } while (
509 this.hasLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasLabel().(uid) ||
510 this.hasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(uid) ||
511 this.hasGlobalscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasGlobal().(uid) ||
512 this.hasReferencescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasReference().(uid)
513 );
514
515 const program = this.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
516 program.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#references.[uid] = true;
517 program.uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids.[uid] = true;
518
519 return uid;
520 }
521
522 /**
523 * Generate an `_id1`.
524 */
525
526 _generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(name): string, iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(i): number) {
527 let id = namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(name);
528 if (iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(i) > 1) id += iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_generateUid().(i);
529 return `_${id}`;
530 }
531
532 generateUidBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, defaultNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(defaultName)?: string) {
533 const parts: NodePartscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/NodePart#[] = [];
534 gatherNodePartsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/gatherNodeParts().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(node), parts);
535
536 let id = parts.joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().("$");
537 id = id.replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().(/^_/, "") || defaultNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(defaultName) || "ref";
538
539 return this.generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().(id.slicescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#slice().(0, 20));
540 }
541
542 /**
543 * Generate a unique identifier based on a node.
544 */
545
546 generateUidIdentifierBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, defaultNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(defaultName)?: string) {
547 return identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().(this.generateUidBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidBasedOnNode().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(node), defaultNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(defaultName)));
548 }
549
550 /**
551 * Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
552 * evaluating it wont result in potentially arbitrary code from being ran. The following are
553 * allowed and determined not to cause side effects:
554 *
555 * - `this` expressions
556 * - `super` expressions
557 * - Bound identifiers
558 */
559
560 isStaticscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#): boolean {
561 if (isThisExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isThisExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node)) || isSuperscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isSuper().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node)) || isTopicReferencescip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTopicReference().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node))) {
562 return true;
563 }
564
565 if (isIdentifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isIdentifier().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node))) {
566 const binding = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
567 if (binding) {
568 return binding.constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant.;
569 } else {
570 return this.hasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
571 }
572 }
573
574 return false;
575 }
576
577 /**
578 * Possibly generate a memoised identifier if it is not static and has consequences.
579 */
580
581 maybeGenerateMemoisedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, dontPushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(dontPush)?: boolean) {
582 if (this.isStaticscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isStatic().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(node))) {
583 return null;
584 } else {
585 const id = this.generateUidIdentifierBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(node));
586 if (!dontPushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(dontPush)) {
587 this.pushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().({ idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id. });
588 return cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(id);
589 }
590 return id;
591 }
592 }
593
594 checkBlockScopedCollisionsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(
595 localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local): Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#,
596 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(kind): BindingKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/BindingKind#,
597 namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(name): string,
598 idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(id): any,
599 ) {
600 // ignore parameters
601 if (kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(kind) === "param") return;
602
603 // Ignore existing binding if it's the name of the current function or
604 // class expression
605 if (localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === "local") return;
606
607 const duplicate =
608 // don't allow duplicate bindings to exist alongside
609 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(kind) === "let" ||
610 localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === "let" ||
611 localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === "const" ||
612 localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === "module" ||
613 // don't allow a local of param with a kind of let
614 (localscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === "param" && kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(kind) === "const");
615
616 if (duplicate) {
617 throw this.hubscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>hub`()..buildErrorscip-typescript npm @babel/traverse 7.20.13 src/`hub.ts`/HubInterface#buildError().(
618 idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(id),
619 `Duplicate declaration "${namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(name)}"`,
620 TypeErrorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/TypeError#,
621 );
622 }
623 }
624
625 renamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(
626 oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(oldName): string,
627 newNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(newName)?: string,
628 // prettier-ignore
629 /* Babel 7 - block?: t.Pattern | t.Scopable */
630 ) {
631 const binding = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(oldName));
632 if (binding) {
633 newNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(newName) ||= this.generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().(oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(oldName)).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.;
634 const renamer = new Renamerscip-typescript npm @babel/traverse 7.20.13 src/scope/lib/`renamer.ts`/Renamer#`<constructor>`().(binding, oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(oldName), newNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#rename().(newName));
635 return process.env.BABEL_8_BREAKING
636 ? renamer.renamescip-typescript npm @babel/traverse 7.20.13 src/scope/lib/`renamer.ts`/Renamer#rename().()
637 : // @ts-expect-error: babel 7->8
638 renamer.renamescip-typescript npm @babel/traverse 7.20.13 src/scope/lib/`renamer.ts`/Renamer#rename().(arguments[2]);
639 }
640 }
641
642 /** @deprecated Not used in our codebase */
643 _renameFromMapscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(
644 mapscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(map): Recordscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Record#<string | symbol, unknown>,
645 oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(oldName): string | symbol,
646 newNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(newName): string | symbol,
647 valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(value): unknown,
648 ) {
649 if (mapscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(map)[oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(oldName)]) {
650 mapscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(map)[newNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(newName)] = valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(value);
651 mapscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(map)[oldNamescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#_renameFromMap().(oldName)] = null;
652 }
653 }
654
655 dumpscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#dump().() {
656 const sep = "-".repeatscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/String#repeat().(60);
657 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(sep);
658 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
659 do {
660 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().("#", scope.blockscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#block..typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayPattern#type.);
661 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.)) {
662 const binding = scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[name];
663 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(" -", name, {
664 constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/constant0:: binding.constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant.,
665 referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/references0:: binding.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#references.,
666 violationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/violations0:: binding.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constantViolations..lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length.,
667 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/kind0:: binding.kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind.,
668 });
669 }
670 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
671 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(sep);
672 }
673
674 // TODO: (Babel 8) Split i in two parameters, and use an object of flags
675 toArrayscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(
676 nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#,
677 iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(i)?: number | boolean,
678 arrayLikeIsIterablescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(arrayLikeIsIterable)?: boolean | void,
679 ) {
680 if (isIdentifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isIdentifier().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node))) {
681 const binding = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
682 if (binding?.constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant. && binding.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#path..isGenericTypescip-typescript npm @babel/traverse 7.20.13 src/path/inference/`index.ts`/isGenericType().("Array")) {
683 return nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node);
684 }
685 }
686
687 if (isArrayExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isArrayExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node))) {
688 return nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node);
689 }
690
691 if (isIdentifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isIdentifier().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node), { namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/name0:: "arguments" })) {
692 return callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(
693 memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(
694 memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(
695 memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("Array"), identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("prototype")),
696 identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("slice"),
697 ),
698 identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("call"),
699 ),
700 [nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node)],
701 );
702 }
703
704 let helperName;
705 const args = [nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(node)];
706 if (iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(i) === true) {
707 // Used in array-spread to create an array.
708 helperName = "toConsumableArray";
709 } else if (typeof iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(i) === "number") {
710 args.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(numericLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/numericLiteral().(iscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(i)));
711
712 // Used in array-rest to create an array from a subset of an iterable.
713 helperName = "slicedToArray";
714 // TODO if (this.hub.isLoose("es6.forOf")) helperName += "-loose";
715 } else {
716 // Used in array-rest to create an array
717 helperName = "toArray";
718 }
719
720 if (arrayLikeIsIterablescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#toArray().(arrayLikeIsIterable)) {
721 args.unshiftscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#unshift().(this.hubscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>hub`()..addHelperscip-typescript npm @babel/traverse 7.20.13 src/`hub.ts`/HubInterface#addHelper().(helperName));
722 helperName = "maybeArrayLike";
723 }
724
725 // @ts-expect-error todo(flow->ts): t.Node is not valid to use in args, function argument typeneeds to be clarified
726 return callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(this.hubscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>hub`()..addHelperscip-typescript npm @babel/traverse 7.20.13 src/`hub.ts`/HubInterface#addHelper().(helperName), args);
727 }
728
729 hasLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasLabel().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasLabel().(name): string) {
730 return !!this.getLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getLabel().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasLabel().(name));
731 }
732
733 getLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getLabel().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getLabel().(name): string) {
734 return this.labelsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#labels..getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#get().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getLabel().(name));
735 }
736
737 registerLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerLabel().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerLabel().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.LabeledStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LabeledStatement#>) {
738 this.labelsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#labels..setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#set().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerLabel().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..labelscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LabeledStatement#label..namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name., pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerLabel().(path));
739 }
740
741 registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) {
742 if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isLabeledStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isLabeledStatement().()) {
743 this.registerLabelscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerLabel().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path));
744 } else if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isFunctionDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunctionDeclaration().()) {
745 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("hoisted", pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).get("id"), pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path));
746 } else if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isVariableDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isVariableDeclaration().()) {
747 const declarations = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).get("declarations");
748 const { kindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#kind. } = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
749 for (const declar of declarations) {
750 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind === "using" ? "const" : kind, declar);
751 }
752 } else if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isClassDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isClassDeclaration().()) {
753 if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..declarescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#declare.) return;
754 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("let", pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path));
755 } else if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isImportDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isImportDeclaration().()) {
756 const isTypeDeclaration =
757 pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..importKindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ImportDeclaration#importKind. === "type" || pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..importKindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ImportDeclaration#importKind. === "typeof";
758 const specifiers = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).get("specifiers");
759 for (const specifier of specifiers) {
760 const isTypeSpecifier =
761 isTypeDeclaration ||
762 (specifier.isImportSpecifierscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isImportSpecifier().() &&
763 (specifier.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..importKindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ImportSpecifier#importKind. === "type" ||
764 specifier.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..importKindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ImportSpecifier#importKind. === "typeof"));
765
766 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(isTypeSpecifier ? "unknown" : "module", specifier);
767 }
768 } else if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).isExportDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isExportDeclaration().()) {
769 // todo: improve babel-types
770 const declar = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path).get("declaration") as NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#;
771 if (
772 declar.isClassDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isClassDeclaration().() ||
773 declar.isFunctionDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunctionDeclaration().() ||
774 declar.isVariableDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isVariableDeclaration().()
775 ) {
776 this.registerDeclarationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(declar);
777 }
778 } else {
779 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().("unknown", pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerDeclaration().(path));
780 }
781 }
782
783 buildUndefinedNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#buildUndefinedNode().() {
784 return unaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/unaryExpression().("void", numericLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/numericLiteral().(0), true);
785 }
786
787 registerConstantViolationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) {
788 const ids = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(path).getBindingIdentifiers();
789 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(ids)) {
790 const binding = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name);
791 if (binding) binding.reassignscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(path));
792 }
793 }
794
795 registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(
796 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind): Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#["kind"scip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind.],
797 pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#,
798 bindingPathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(bindingPath): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(path),
799 ) {
800 if (!kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind)) throw new ReferenceErrorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ReferenceError#("no `kind`");
801
802 if (pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(path).isVariableDeclarationscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isVariableDeclaration().()) {
803 const declarators: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#> = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(path).get("declarations");
804 for (const declar of declarators) {
805 this.registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind), declar);
806 }
807 return;
808 }
809
810 const parent = this.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
811 const ids = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(path).getOuterBindingIdentifiers(true);
812
813 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(ids)) {
814 parent.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#references.[name] = true;
815
816 for (const id of ids[name]) {
817 const local = this.getOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(name);
818
819 if (local) {
820 // same identifier so continue safely as we're likely trying to register it
821 // multiple times
822 if (local.identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#identifier. === id) continue;
823
824 this.checkBlockScopedCollisionsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#checkBlockScopedCollisions().(local, kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind), name, id);
825 }
826
827 // A redeclaration of an existing variable is a modification
828 if (local) {
829 this.registerConstantViolationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(bindingPathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(bindingPath));
830 } else {
831 this.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[name] = new Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().({
832 identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:identifier.: id,
833 scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:scope.: this,
834 pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:path.: bindingPathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(bindingPath),
835 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:kind.: kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind),
836 });
837 }
838 }
839 }
840 }
841
842 addGlobalscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.JSXIdentifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/JSXIdentifier#) {
843 this.globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals.[nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.] = nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(node);
844 }
845
846 hasUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasUid().(name): string): boolean {
847 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
848
849 do {
850 if (scope.uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasUid().(name)]) return true;
851 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
852
853 return false;
854 }
855
856 hasGlobalscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasGlobal().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasGlobal().(name): string): boolean {
857 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
858
859 do {
860 if (scope.globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasGlobal().(name)]) return true;
861 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
862
863 return false;
864 }
865
866 hasReferencescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasReference().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasReference().(name): string): boolean {
867 return !!this.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().().referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#references.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasReference().(name)];
868 }
869
870 isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly)?: boolean): boolean {
871 if (isIdentifierscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isIdentifier().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
872 const binding = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
873 if (!binding) return false;
874 if (constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly)) return binding.constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant.;
875 return true;
876 } else if (
877 isThisExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isThisExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) ||
878 isMetaPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMetaProperty().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) ||
879 isTopicReferencescip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTopicReference().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) ||
880 isPrivateNamescip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isPrivateName().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))
881 ) {
882 return true;
883 } else if (isClassscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClass().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
884 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).superClassscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#superClass. && !this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).superClassscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#superClass., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) {
885 return false;
886 }
887 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).decoratorsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#decorators.?.lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. > 0) {
888 return false;
889 }
890 return this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassDeclaration#body., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly));
891 } else if (isClassBodyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isClassBody().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
892 for (const method of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassBody#body.) {
893 if (!this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(method, constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
894 }
895 return true;
896 } else if (isBinaryscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isBinary().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
897 return (
898 this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).leftscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BinaryExpression#left., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly)) &&
899 this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BinaryExpression#right., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))
900 );
901 } else if (isArrayExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isArrayExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) || isTupleExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTupleExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
902 for (const elem of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).elementsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#elements.) {
903 if (elem !== null && !this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(elem, constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
904 }
905 return true;
906 } else if (isObjectExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isObjectExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) || isRecordExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isRecordExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
907 for (const prop of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).propertiesscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ObjectExpression#properties.) {
908 if (!this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(prop, constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
909 }
910 return true;
911 } else if (isMethodscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMethod().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
912 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).computedscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassMethod#computed. && !this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).keyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassMethod#key., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
913 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).decoratorsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassMethod#decorators.?.lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. > 0) {
914 return false;
915 }
916 return true;
917 } else if (isPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isProperty().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
918 // @ts-expect-error todo(flow->ts): computed in not present on private properties
919 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).computed && !this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).keyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassAccessorProperty#key., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
920 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).decoratorsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassAccessorProperty#decorators.?.lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. > 0) {
921 return false;
922 }
923 if (isObjectPropertyscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isObjectProperty().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node)) || nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).staticscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassAccessorProperty#static.) {
924 if (nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).valuescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassAccessorProperty#value. !== null && !this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).valuescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ClassAccessorProperty#value., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) {
925 return false;
926 }
927 }
928 return true;
929 } else if (isUnaryExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isUnaryExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
930 return this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).argumentscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/UnaryExpression#argument., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly));
931 } else if (isTaggedTemplateExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTaggedTemplateExpression().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
932 return (
933 matchesPatternscip-typescript npm @babel/types 7.20.7 src/validators/`matchesPattern.ts`/matchesPattern().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).tagscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/TaggedTemplateExpression#tag., "String.raw") &&
934 !this.hasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().("String", true) &&
935 this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).quasiscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/TaggedTemplateExpression#quasi., constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))
936 );
937 } else if (isTemplateLiteralscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isTemplateLiteral().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node))) {
938 for (const expression of nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node).expressionsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/TemplateLiteral#expressions.) {
939 if (!this.isPurescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(expression, constantsOnlyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(constantsOnly))) return false;
940 }
941 return true;
942 } else {
943 return isPureishscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isPureish().(nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#isPure().(node));
944 }
945 }
946
947 /**
948 * Set some arbitrary data on the current scope.
949 */
950
951 setDatascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#setData().(keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#setData().(key): string | symbol, valscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#setData().(val): any) {
952 return (this.datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data.[keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#setData().(key)] = valscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#setData().(val));
953 }
954
955 /**
956 * Recursively walk up scope tree looking for the data `key`.
957 */
958
959 getDatascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getData().(keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getData().(key): string | symbol): any {
960 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
961 do {
962 const data = scope.datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data.[keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getData().(key)];
963 if (data != null) return data;
964 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
965 }
966
967 /**
968 * Recursively walk up scope tree looking for the data `key` and if it exists,
969 * remove it.
970 */
971
972 removeDatascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeData().(keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeData().(key): string) {
973 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
974 do {
975 const data = scope.datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data.[keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeData().(key)];
976 if (data != null) scope.datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data.[keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeData().(key)] = null;
977 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
978 }
979
980 initscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#init().() {
981 if (!this.initedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#inited.) {
982 this.initedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#inited. = true;
983 this.crawlscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawl().();
984 }
985 }
986
987 crawlscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawl().() {
988 const path = this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
989
990 this.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#references. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
991 this.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
992 this.globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
993 this.uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
994 this.datascip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#data. = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
995
996 const programParent = this.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().();
997 if (programParent.crawlingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawling.) return;
998
999 const state: CollectVisitorStatescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState# = {
1000 referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#references.: [],
1001 constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations.: [],
1002 assignmentsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#assignments.: [],
1003 };
1004
1005 this.crawlingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawling. = true;
1006 // traverse does not visit the root node, here we explicitly collect
1007 // root node binding info when the root is not a Program.
1008 if (path.typescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#type. !== "Program" && collectorVisitorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/collectorVisitor.._explodedscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/InternalVisitorFlags#typeLiteral0:_exploded.) {
1009 // @ts-expect-error when collectorVisitor is exploded, `enter` always exists
1010 for (const visit of collectorVisitorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/collectorVisitor..enterscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/VisitNodeObject#enter.) {
1011 visit(path, state);
1012 }
1013 const typeVisitors = collectorVisitorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/collectorVisitor.[path.typescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#type.];
1014 if (typeVisitors) {
1015 // @ts-expect-error when collectorVisitor is exploded, `enter` always exists
1016 for (const visit of typeVisitors.enter) {
1017 visit(path, state);
1018 }
1019 }
1020 }
1021 path.traversescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#traverse().(collectorVisitorscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/collectorVisitor., state);
1022 this.crawlingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#crawling. = false;
1023
1024 // register assignments
1025 for (const path of state.assignmentsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#assignments.) {
1026 // register undeclared bindings as globals
1027 const ids = path.getBindingIdentifiers();
1028 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(ids)) {
1029 if (path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name)) continue;
1030 programParent.addGlobalscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(ids[name]);
1031 }
1032
1033 // register as constant violation
1034 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerConstantViolationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(path);
1035 }
1036
1037 // register references
1038 for (const ref of state.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#references.) {
1039 const binding = ref.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(ref.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..namescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#name.);
1040 if (binding) {
1041 binding.referencescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(ref);
1042 } else {
1043 programParent.addGlobalscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#addGlobal().(ref.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.);
1044 }
1045 }
1046
1047 // register constant violations
1048 for (const path of state.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/CollectVisitorState#constantViolations.) {
1049 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerConstantViolationscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerConstantViolation().(path);
1050 }
1051 }
1052
1053 pushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts): {
1054 idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id.: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.LValscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LVal#;
1055 initscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:init.?: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
1056 uniquescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:unique.?: boolean;
1057 _blockHoistscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:_blockHoist.?: number | undefined;
1058 kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:kind.?: "var" | "let" | "const";
1059 }) {
1060 let path = this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
1061
1062 if (path.isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().()) {
1063 path = this.getPatternParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getPatternParent().().pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
1064 } else if (!path.isBlockStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isBlockStatement().() && !path.isProgramscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isProgram().()) {
1065 path = this.getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().().pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
1066 }
1067
1068 if (path.isSwitchStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isSwitchStatement().()) {
1069 path = (this.getFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getFunctionParent().() || this.getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().()).pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
1070 }
1071
1072 if (path.isLoopscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isLoop().() || path.isCatchClausescip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isCatchClause().() || path.isFunctionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunction().()) {
1073 // @ts-expect-error TS can not infer NodePath<Loop> | NodePath<CatchClause> as NodePath<Loop | CatchClause>
1074 path.ensureBlockscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#ensureBlock().();
1075 // @ts-expect-error todo(flow->ts): improve types
1076 path = path.get("body");
1077 }
1078
1079 const unique = optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts).uniquescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:unique.;
1080 const kind = optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts).kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:kind. || "var";
1081 const blockHoist = optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)._blockHoistscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:_blockHoist. == null ? 2 : optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)._blockHoistscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:_blockHoist.;
1082
1083 const dataKey = `declaration:${kind}:${blockHoist}`;
1084 let declarPath = !unique && path.getDatascip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#getData().(dataKey);
1085
1086 if (!declarPath) {
1087 const declar = variableDeclarationscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclaration().(kind, []);
1088 // @ts-expect-error todo(flow->ts): avoid modifying nodes
1089 declar._blockHoist = blockHoist;
1090
1091 [declarPath] = (path as NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.BlockStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BlockStatement#>).unshiftContainerscip-typescript npm @babel/traverse 7.20.13 src/path/`modification.ts`/unshiftContainer().(
1092 "body",
1093 [declar],
1094 );
1095 if (!unique) path.setDatascip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#setData().(dataKey, declarPath);
1096 }
1097
1098 const declarator = variableDeclaratorscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclarator().(optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts).idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id., optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts).initscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:init.);
1099 const len = declarPath.node.declarations.push(declarator);
1100 path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..registerBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#registerBinding().(kind, declarPath.get("declarations")[len - 1]);
1101 }
1102
1103 /**
1104 * Walk up to the top of the scope tree and get the `Program`.
1105 */
1106
1107 getProgramParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getProgramParent().() {
1108 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1109 do {
1110 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isProgramscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isProgram().()) {
1111 return scope;
1112 }
1113 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1114 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Couldn't find a Program");
1115 }
1116
1117 /**
1118 * Walk up the scope tree until we hit either a Function or return null.
1119 */
1120
1121 getFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getFunctionParent().(): Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# | null {
1122 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1123 do {
1124 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunctionParent().()) {
1125 return scope;
1126 }
1127 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1128 return null;
1129 }
1130
1131 /**
1132 * Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the
1133 * very top and hit Program.
1134 */
1135
1136 getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().() {
1137 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1138 do {
1139 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isBlockParentscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isBlockParent().()) {
1140 return scope;
1141 }
1142 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1143 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
1144 "We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...",
1145 );
1146 }
1147
1148 /**
1149 * Walk up from a pattern scope (function param initializer) until we hit a non-pattern scope,
1150 * then returns its block parent
1151 * @returns An ancestry scope whose path is a block parent
1152 */
1153 getPatternParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getPatternParent().() {
1154 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1155 do {
1156 if (!scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().()) {
1157 return scope.getBlockParentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBlockParent().();
1158 }
1159 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`()..parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1160 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
1161 "We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...",
1162 );
1163 }
1164
1165 /**
1166 * Walks the scope tree and gathers **all** bindings.
1167 */
1168
1169 getAllBindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getAllBindings().(): Recordscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Record#<string, Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#> {
1170 const ids = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
1171
1172 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1173 do {
1174 for (const key of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.)) {
1175 if (key in ids === false) {
1176 ids[key] = scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[key];
1177 }
1178 }
1179 scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().;
1180 } while (scope);
1181
1182 return ids;
1183 }
1184
1185 /**
1186 * Walks the scope tree and gathers all declarations of `kind`.
1187 */
1188
1189 getAllBindingsOfKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getAllBindingsOfKind().(...kindsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getAllBindingsOfKind().(kinds): string[]): Recordscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Record#<string, Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#> {
1190 const ids = Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.createscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#create().(null);
1191
1192 for (const kind of kindsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getAllBindingsOfKind().(kinds)) {
1193 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1194 do {
1195 for (const name of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.)) {
1196 const binding = scope.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[name];
1197 if (binding.kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. === kind) ids[name] = binding;
1198 }
1199 scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().;
1200 } while (scope);
1201 }
1202
1203 return ids;
1204 }
1205
1206 bindingIdentifierEqualsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindingIdentifierEquals().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindingIdentifierEquals().(name): string, nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindingIdentifierEquals().(node): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#): boolean {
1207 return this.getBindingIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBindingIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindingIdentifierEquals().(name)) === nodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindingIdentifierEquals().(node);
1208 }
1209
1210 getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name): string): Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# | undefined {
1211 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1212 let previousPath;
1213
1214 do {
1215 const binding = scope.getOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name));
1216 if (binding) {
1217 // Check if a pattern is a part of parameter expressions.
1218 // Note: for performance reason we skip checking previousPath.parentPath.isFunction()
1219 // because `scope.path` is validated as scope in packages/babel-types/src/validators/isScope.js
1220 // That is, if a scope path is pattern, its parent must be Function/CatchClause
1221
1222 // Spec 9.2.10.28: The closure created by this expression should not have visibility of
1223 // declarations in the function body. If the binding is not a `param`-kind (as function parameters)
1224 // or `local`-kind (as id in function expression),
1225 // then it must be defined inside the function body, thus it should be skipped
1226 if (
1227 previousPath?.isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().() &&
1228 binding.kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. !== "param" &&
1229 binding.kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. !== "local"
1230 ) {
1231 // do nothing
1232 } else {
1233 return binding;
1234 }
1235 } else if (
1236 !binding &&
1237 namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(name) === "arguments" &&
1238 scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isFunctionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunction().() &&
1239 !scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isArrowFunctionExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isArrowFunctionExpression().()
1240 ) {
1241 break;
1242 }
1243 previousPath = scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path.;
1244 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1245 }
1246
1247 getOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(name): string): Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# | undefined {
1248 return this.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(name)];
1249 }
1250
1251 // todo: return probably can be undefined…
1252 getBindingIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBindingIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBindingIdentifier().(name): string): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# {
1253 return this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBindingIdentifier().(name))?.identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#identifier.;
1254 }
1255
1256 // todo: flow->ts return probably can be undefined
1257 getOwnBindingIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBindingIdentifier().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBindingIdentifier().(name): string): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# {
1258 const binding = this.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBindingIdentifier().(name)];
1259 return binding?.identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#identifier.;
1260 }
1261
1262 hasOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasOwnBinding().(name): string) {
1263 return !!this.getOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasOwnBinding().(name));
1264 }
1265
1266 // By default, we consider generated UIDs as bindings.
1267 // This is because they are almost always used to declare variables,
1268 // and since the scope isn't always up-to-date it's better to assume that
1269 // there is a variable with that name. The `noUids` option can be used to
1270 // turn off this behavior, for example if you know that the generate UID
1271 // was used to declare a variable in a different scope.
1272 hasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(
1273 namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name): string,
1274 optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts)?: boolean | { noGlobals?: boolean; noUids?: boolean },
1275 ) {
1276 if (!namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name)) return false;
1277 if (this.hasOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name))) return true;
1278 {
1279 // TODO: Only accept the object form.
1280 if (typeof optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts) === "boolean") optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts) = { noGlobalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/noGlobals0:: optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts) };
1281 }
1282 if (this.parentHasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name), optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts))) return true;
1283 if (!optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts)?.noUids && this.hasUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasUid().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name))) return true;
1284 if (!optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts)?.noGlobals && Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#.globalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#globals..includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name))) return true;
1285 if (!optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(opts)?.noGlobals && Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#.contextVariablesscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#contextVariables..includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(name))) return true;
1286 return false;
1287 }
1288
1289 parentHasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(
1290 namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(name): string,
1291 optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(opts)?: { noGlobalsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(opts)typeLiteral456:noGlobals.?: boolean; noUidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(opts)typeLiteral456:noUids.?: boolean },
1292 ) {
1293 return this.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().?.hasBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(name), optsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#parentHasBinding().(opts));
1294 }
1295
1296 /**
1297 * Move a binding of `name` to another `scope`.
1298 */
1299
1300 moveBindingToscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(name): string, scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(scope): Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#) {
1301 const info = this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(name));
1302 if (info) {
1303 info.scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#scope..removeOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(name));
1304 info.scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#scope. = scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(scope);
1305 scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(scope).bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#moveBindingTo().(name)] = info;
1306 }
1307 }
1308
1309 removeOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeOwnBinding().(name): string) {
1310 delete this.bindingsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#bindings.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeOwnBinding().(name)];
1311 }
1312
1313 removeBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(name): string) {
1314 // clear literal binding
1315 this.getBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#getBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(name))?.scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#scope..removeOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeOwnBinding().(namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(name));
1316
1317 // clear uids with this name - https://github.com/babel/babel/issues/2101
1318 let scope: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# = this;
1319 do {
1320 if (scope.uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(name)]) {
1321 scope.uidsscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#uids.[namescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#removeBinding().(name)] = false;
1322 }
1323 } while ((scope = scope.parentscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#`<get>parent`().));
1324 }
1325 }