@@ -158,30 +158,31 @@ class FunctionTracer {
158
158
this . scan ( ast . declarations ) ;
159
159
}
160
160
break ;
161
- case 'VariableDeclarator' : {
162
- const { currentContext } = this ;
163
- const inForLoopInit = this . hasState ( states . inForLoopInit ) ;
164
- const declaration = {
165
- ast : ast ,
166
- context : currentContext ,
167
- name : ast . id . name ,
168
- origin : 'declaration' ,
169
- inForLoopInit,
170
- inForLoopTest : null ,
171
- assignable : currentContext === this . currentFunctionContext || ( ! inForLoopInit && ! currentContext . hasOwnProperty ( ast . id . name ) ) ,
172
- suggestedType : null ,
173
- valueType : null ,
174
- dependencies : null ,
175
- isSafe : null ,
176
- } ;
177
- if ( ! currentContext [ ast . id . name ] ) {
178
- currentContext [ ast . id . name ] = declaration ;
161
+ case 'VariableDeclarator' :
162
+ {
163
+ const { currentContext } = this ;
164
+ const inForLoopInit = this . hasState ( states . inForLoopInit ) ;
165
+ const declaration = {
166
+ ast : ast ,
167
+ context : currentContext ,
168
+ name : ast . id . name ,
169
+ origin : 'declaration' ,
170
+ inForLoopInit,
171
+ inForLoopTest : null ,
172
+ assignable : currentContext === this . currentFunctionContext || ( ! inForLoopInit && ! currentContext . hasOwnProperty ( ast . id . name ) ) ,
173
+ suggestedType : null ,
174
+ valueType : null ,
175
+ dependencies : null ,
176
+ isSafe : null ,
177
+ } ;
178
+ if ( ! currentContext [ ast . id . name ] ) {
179
+ currentContext [ ast . id . name ] = declaration ;
180
+ }
181
+ this . declarations . push ( declaration ) ;
182
+ this . scan ( ast . id ) ;
183
+ this . scan ( ast . init ) ;
184
+ break ;
179
185
}
180
- this . declarations . push ( declaration ) ;
181
- this . scan ( ast . id ) ;
182
- this . scan ( ast . init ) ;
183
- break ;
184
- }
185
186
case 'FunctionExpression' :
186
187
case 'FunctionDeclaration' :
187
188
if ( this . runningContexts . length === 0 ) {
@@ -195,51 +196,53 @@ class FunctionTracer {
195
196
this . scan ( ast . consequent ) ;
196
197
if ( ast . alternate ) this . scan ( ast . alternate ) ;
197
198
break ;
198
- case 'ForStatement' : {
199
- let testIdentifiers ;
200
- const context = this . newContext ( ( ) => {
201
- this . pushState ( states . inForLoopInit ) ;
202
- this . scan ( ast . init ) ;
203
- this . popState ( states . inForLoopInit ) ;
199
+ case 'ForStatement' :
200
+ {
201
+ let testIdentifiers ;
202
+ const context = this . newContext ( ( ) => {
203
+ this . pushState ( states . inForLoopInit ) ;
204
+ this . scan ( ast . init ) ;
205
+ this . popState ( states . inForLoopInit ) ;
204
206
205
- testIdentifiers = this . getIdentifiers ( ( ) => {
206
- this . scan ( ast . test ) ;
207
- } ) ;
207
+ testIdentifiers = this . getIdentifiers ( ( ) => {
208
+ this . scan ( ast . test ) ;
209
+ } ) ;
208
210
209
- this . scan ( ast . update ) ;
210
- this . newContext ( ( ) => {
211
- this . scan ( ast . body ) ;
211
+ this . scan ( ast . update ) ;
212
+ this . newContext ( ( ) => {
213
+ this . scan ( ast . body ) ;
214
+ } ) ;
212
215
} ) ;
213
- } ) ;
214
216
215
- if ( testIdentifiers ) {
216
- for ( const p in context ) {
217
- if ( p === '@contextType' ) continue ;
218
- if ( testIdentifiers . indexOf ( p ) > - 1 ) {
219
- context [ p ] . inForLoopTest = true ;
217
+ if ( testIdentifiers ) {
218
+ for ( const p in context ) {
219
+ if ( p === '@contextType' ) continue ;
220
+ if ( testIdentifiers . indexOf ( p ) > - 1 ) {
221
+ context [ p ] . inForLoopTest = true ;
222
+ }
220
223
}
221
224
}
225
+ break ;
222
226
}
223
- break ;
224
- }
225
227
case 'DoWhileStatement' :
226
228
case 'WhileStatement' :
227
229
this . newContext ( ( ) => {
228
230
this . scan ( ast . body ) ;
229
231
this . scan ( ast . test ) ;
230
232
} ) ;
231
233
break ;
232
- case 'Identifier' : {
233
- if ( this . isState ( states . trackIdentifiers ) ) {
234
- this . trackedIdentifiers . push ( ast . name ) ;
234
+ case 'Identifier' :
235
+ {
236
+ if ( this . isState ( states . trackIdentifiers ) ) {
237
+ this . trackedIdentifiers . push ( ast . name ) ;
238
+ }
239
+ this . identifiers . push ( {
240
+ context : this . currentContext ,
241
+ declaration : this . getDeclaration ( ast . name ) ,
242
+ ast,
243
+ } ) ;
244
+ break ;
235
245
}
236
- this . identifiers . push ( {
237
- context : this . currentContext ,
238
- declaration : this . getDeclaration ( ast . name ) ,
239
- ast,
240
- } ) ;
241
- break ;
242
- }
243
246
case 'ReturnStatement' :
244
247
this . returnStatements . push ( ast ) ;
245
248
this . scan ( ast . argument ) ;
0 commit comments