MCPcopy Create free account
hub / github.com/arktypeio/arktype / visit

Method visit

ark/aot/scope.ts:195–353  ·  view source on GitHub ↗
(node: Node | null | undefined, parent: Node)

Source from the content-addressed store, hash-verified

193 }
194
195 private visit(node: Node | null | undefined, parent: Node): void {
196 if (!node) return
197 node.parent = parent
198 switch (node.type) {
199 case "Identifier":
200 this.reference(node as IdentifierReference, false)
201 return
202 case "FunctionDeclaration":
203 case "FunctionExpression":
204 case "ArrowFunctionExpression":
205 return this.visitFunction(node)
206 case "ClassDeclaration":
207 case "ClassExpression":
208 return this.visitClass(node)
209 case "BlockStatement":
210 case "StaticBlock":
211 return this.inScope(node, () => this.visitAll(node.body, node))
212 case "ForStatement":
213 case "SwitchStatement":
214 return this.inScope(node, () => this.visitChildren(node))
215 case "ForInStatement":
216 case "ForOfStatement":
217 return this.inScope(node, () => {
218 if (node.left.type === "VariableDeclaration")
219 this.visit(node.left, node)
220 else this.visitTarget(node.left, node)
221 this.visit(node.right, node)
222 this.visit(node.body, node)
223 })
224 case "CatchClause":
225 return this.inScope(node, () => {
226 if (node.param) this.bindPattern(node.param, "catch", node, node)
227 this.visit(node.body, node)
228 })
229 case "VariableDeclaration":
230 return this.visitVariables(node)
231 case "ImportDeclaration":
232 if (node.importKind === "type") return
233 for (const specifier of node.specifiers) {
234 specifier.parent = node
235 if (
236 specifier.type === "ImportSpecifier" &&
237 specifier.importKind === "type"
238 )
239 continue
240 this.bind(specifier.local, "import", specifier, specifier)
241 }
242 return
243 case "ExportNamedDeclaration":
244 return this.visitExport(node)
245 case "ExportDefaultDeclaration": {
246 this.visit(node.declaration, node)
247 const [id] = declaredIds(node.declaration)
248 const binding = id && this.bindingsById.get(id)
249 this.exportsByName.default =
250 binding ?
251 { kind: "binding", binding }
252 : { kind: "expression", node: node.declaration }

Callers 10

constructorMethod · 0.95
visitChildrenMethod · 0.95
visitAllMethod · 0.95
visitScopeMethod · 0.95
visitClassMethod · 0.95
visitPropertyMethod · 0.95
visitVariablesMethod · 0.95
visitExportMethod · 0.95
visitTargetMethod · 0.95
bindPatternMethod · 0.95

Calls 15

referenceMethod · 0.95
visitFunctionMethod · 0.95
visitClassMethod · 0.95
inScopeMethod · 0.95
visitAllMethod · 0.95
visitChildrenMethod · 0.95
visitTargetMethod · 0.95
bindPatternMethod · 0.95
visitVariablesMethod · 0.95
bindMethod · 0.95
visitExportMethod · 0.95
visitPropertyMethod · 0.95

Tested by

no test coverage detected