@@ -18,9 +18,7 @@ export function walkIdentifiers(
18
18
isReference : boolean ,
19
19
isLocal : boolean
20
20
) => void ,
21
- onNode ?: ( node : Node , parent : Node , parentStack : Node [ ] ) => void | boolean ,
22
21
includeAll = false ,
23
- analyzeScope = true ,
24
22
parentStack : Node [ ] = [ ] ,
25
23
knownIds : Record < string , number > = Object . create ( null )
26
24
) {
@@ -41,11 +39,8 @@ export function walkIdentifiers(
41
39
) {
42
40
return this . skip ( )
43
41
}
44
- if ( onNode && onNode ( node , parent ! , parentStack ) === false ) {
45
- return this . skip ( )
46
- }
47
42
if ( node . type === 'Identifier' ) {
48
- const isLocal = analyzeScope && ! ! knownIds [ node . name ]
43
+ const isLocal = ! ! knownIds [ node . name ]
49
44
const isRefed = isReferencedIdentifier ( node , parent ! , parentStack )
50
45
if ( includeAll || ( isRefed && ! isLocal ) ) {
51
46
onIdentifier ( node , parent ! , parentStack , isRefed , isLocal )
@@ -56,24 +51,20 @@ export function walkIdentifiers(
56
51
) {
57
52
// mark property in destructure pattern
58
53
; ( node as any ) . inPattern = true
59
- } else if ( analyzeScope ) {
60
- if ( isFunctionType ( node ) ) {
61
- // walk function expressions and add its arguments to known identifiers
62
- // so that we don't prefix them
63
- walkFunctionParams ( node , id =>
64
- markScopeIdentifier ( node , id , knownIds )
65
- )
66
- } else if ( node . type === 'BlockStatement' ) {
67
- // #3445 record block-level local variables
68
- walkBlockDeclarations ( node , id =>
69
- markScopeIdentifier ( node , id , knownIds )
70
- )
71
- }
54
+ } else if ( isFunctionType ( node ) ) {
55
+ // walk function expressions and add its arguments to known identifiers
56
+ // so that we don't prefix them
57
+ walkFunctionParams ( node , id => markScopeIdentifier ( node , id , knownIds ) )
58
+ } else if ( node . type === 'BlockStatement' ) {
59
+ // #3445 record block-level local variables
60
+ walkBlockDeclarations ( node , id =>
61
+ markScopeIdentifier ( node , id , knownIds )
62
+ )
72
63
}
73
64
} ,
74
65
leave ( node : Node & { scopeIds ?: Set < string > } , parent : Node | undefined ) {
75
66
parent && parentStack . pop ( )
76
- if ( analyzeScope && node !== rootExp && node . scopeIds ) {
67
+ if ( node !== rootExp && node . scopeIds ) {
77
68
for ( const id of node . scopeIds ) {
78
69
knownIds [ id ] --
79
70
if ( knownIds [ id ] === 0 ) {
@@ -189,13 +180,13 @@ export function extractIdentifiers(
189
180
break
190
181
191
182
case 'ObjectPattern' :
192
- param . properties . forEach ( prop => {
183
+ for ( const prop of param . properties ) {
193
184
if ( prop . type === 'RestElement' ) {
194
185
extractIdentifiers ( prop . argument , nodes )
195
186
} else {
196
187
extractIdentifiers ( prop . value , nodes )
197
188
}
198
- } )
189
+ }
199
190
break
200
191
201
192
case 'ArrayPattern' :
0 commit comments