walkIdentifiers() — vue Function Reference
Architecture documentation for the walkIdentifiers() function in babelUtils.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 6821e51e_382f_8ff8_ca9d_3b77f896018a["walkIdentifiers()"] 946e0fa6_6c05_b820_0bd7_980d6d869192["babelUtils.ts"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|defined in| 946e0fa6_6c05_b820_0bd7_980d6d869192 6195696d_b4e9_b5d7_3dd5_1966a03d855f["compileScript()"] 6195696d_b4e9_b5d7_3dd5_1966a03d855f -->|calls| 6821e51e_382f_8ff8_ca9d_3b77f896018a 72c10b69_fb02_fbf6_63d5_43832727d4f7["processExp()"] 72c10b69_fb02_fbf6_63d5_43832727d4f7 -->|calls| 6821e51e_382f_8ff8_ca9d_3b77f896018a fefea729_cf80_e4f2_675b_000b41fc85a5["prefixIdentifiers()"] fefea729_cf80_e4f2_675b_000b41fc85a5 -->|calls| 6821e51e_382f_8ff8_ca9d_3b77f896018a 6a4dcb82_14bf_768b_c362_246755645991["isReferencedIdentifier()"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|calls| 6a4dcb82_14bf_768b_c362_246755645991 2da3a667_48eb_9608_1220_cf672cac17b7["isFunctionType()"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|calls| 2da3a667_48eb_9608_1220_cf672cac17b7 414e5246_5f40_b96a_8130_5a96cb9d8426["walkFunctionParams()"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|calls| 414e5246_5f40_b96a_8130_5a96cb9d8426 7e8e68e9_ea35_71dc_11c1_49e8bba80b55["markScopeIdentifier()"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|calls| 7e8e68e9_ea35_71dc_11c1_49e8bba80b55 5e4207f6_76c5_de5d_945f_5dc740607887["walkBlockDeclarations()"] 6821e51e_382f_8ff8_ca9d_3b77f896018a -->|calls| 5e4207f6_76c5_de5d_945f_5dc740607887 style 6821e51e_382f_8ff8_ca9d_3b77f896018a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/compiler-sfc/src/babelUtils.ts lines 15–85
export function walkIdentifiers(
root: Node,
onIdentifier: (
node: Identifier,
parent: Node,
parentStack: Node[],
isReference: boolean,
isLocal: boolean
) => void,
onNode?: (node: Node) => void
) {
const includeAll = false
const parentStack: Node[] = []
const knownIds: Record<string, number> = Object.create(null)
const rootExp =
root.type === 'Program' &&
root.body[0].type === 'ExpressionStatement' &&
root.body[0].expression
;(walk as any)(root, {
enter(node: Node & { scopeIds?: Set<string> }, parent: Node | undefined) {
parent && parentStack.push(parent)
if (
parent &&
parent.type.startsWith('TS') &&
parent.type !== 'TSAsExpression' &&
parent.type !== 'TSNonNullExpression' &&
parent.type !== 'TSTypeAssertion'
) {
return this.skip()
}
if (onNode) onNode(node)
if (node.type === 'Identifier') {
const isLocal = !!knownIds[node.name]
const isRefed = isReferencedIdentifier(node, parent!, parentStack)
if (includeAll || (isRefed && !isLocal)) {
onIdentifier(node, parent!, parentStack, isRefed, isLocal)
}
} else if (
node.type === 'ObjectProperty' &&
parent!.type === 'ObjectPattern'
) {
// mark property in destructure pattern
;(node as any).inPattern = true
} else if (isFunctionType(node)) {
// walk function expressions and add its arguments to known identifiers
// so that we don't prefix them
walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds))
} else if (node.type === 'BlockStatement') {
// #3445 record block-level local variables
walkBlockDeclarations(node, id =>
markScopeIdentifier(node, id, knownIds)
)
}
},
leave(node: Node & { scopeIds?: Set<string> }, parent: Node | undefined) {
parent && parentStack.pop()
if (node !== rootExp && node.scopeIds) {
for (const id of node.scopeIds) {
knownIds[id]--
if (knownIds[id] === 0) {
delete knownIds[id]
}
}
}
}
})
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does walkIdentifiers() do?
walkIdentifiers() is a function in the vue codebase, defined in packages/compiler-sfc/src/babelUtils.ts.
Where is walkIdentifiers() defined?
walkIdentifiers() is defined in packages/compiler-sfc/src/babelUtils.ts at line 15.
What does walkIdentifiers() call?
walkIdentifiers() calls 5 function(s): isFunctionType, isReferencedIdentifier, markScopeIdentifier, walkBlockDeclarations, walkFunctionParams.
What calls walkIdentifiers()?
walkIdentifiers() is called by 3 function(s): compileScript, prefixIdentifiers, processExp.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free