@@ -27,11 +27,6 @@ import 'package:analyzer/src/generated/utilities_dart.dart';
27
27
* build elements outside of function bodies and initializers.
28
28
*/
29
29
class ApiElementBuilder extends _BaseElementBuilder {
30
- /**
31
- * A flag indicating whether a variable declaration is within the body of a method or function.
32
- */
33
- bool _inFunction = false ;
34
-
35
30
/**
36
31
* A table mapping field names to field elements for the fields defined in the current class, or
37
32
* `null` if we are not in the scope of a class.
@@ -47,13 +42,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
47
42
CompilationUnitElementImpl compilationUnitElement)
48
43
: super (initialHolder, compilationUnitElement);
49
44
50
- /**
51
- * Prepares for incremental resolution of a function body.
52
- */
53
- void initForFunctionBodyIncrementalResolution () {
54
- _inFunction = true ;
55
- }
56
-
57
45
@override
58
46
Object visitAnnotation (Annotation node) {
59
47
// Although it isn't valid to do so because closures are not constant
@@ -149,13 +137,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
149
137
@override
150
138
Object visitConstructorDeclaration (ConstructorDeclaration node) {
151
139
ElementHolder holder = new ElementHolder ();
152
- bool wasInFunction = _inFunction;
153
- _inFunction = true ;
154
- try {
155
- _visitChildren (holder, node);
156
- } finally {
157
- _inFunction = wasInFunction;
158
- }
140
+ _visitChildren (holder, node);
159
141
FunctionBody body = node.body;
160
142
SimpleIdentifier constructorName = node.name;
161
143
ConstructorElementImpl element =
@@ -281,16 +263,10 @@ class ApiElementBuilder extends _BaseElementBuilder {
281
263
FunctionExpression expression = node.functionExpression;
282
264
if (expression != null ) {
283
265
ElementHolder holder = new ElementHolder ();
284
- bool wasInFunction = _inFunction;
285
- _inFunction = true ;
286
- try {
287
- _visitChildren (holder, node);
288
- } finally {
289
- _inFunction = wasInFunction;
290
- }
266
+ _visitChildren (holder, node);
291
267
FunctionBody body = expression.body;
292
268
Token property = node.propertyKeyword;
293
- if (property == null || _inFunction ) {
269
+ if (property == null ) {
294
270
SimpleIdentifier functionName = node.name;
295
271
FunctionElementImpl element =
296
272
new FunctionElementImpl .forNode (functionName);
@@ -311,13 +287,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
311
287
if (body.isGenerator) {
312
288
element.generator = true ;
313
289
}
314
- if (_inFunction) {
315
- Block enclosingBlock = node.getAncestor ((node) => node is Block );
316
- if (enclosingBlock != null ) {
317
- element.setVisibleRange (
318
- enclosingBlock.offset, enclosingBlock.length);
319
- }
320
- }
321
290
if (node.returnType == null ) {
322
291
element.hasImplicitReturnType = true ;
323
292
}
@@ -412,13 +381,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
412
381
return super .visitFunctionExpression (node);
413
382
}
414
383
ElementHolder holder = new ElementHolder ();
415
- bool wasInFunction = _inFunction;
416
- _inFunction = true ;
417
- try {
418
- _visitChildren (holder, node);
419
- } finally {
420
- _inFunction = wasInFunction;
421
- }
384
+ _visitChildren (holder, node);
422
385
FunctionBody body = node.body;
423
386
FunctionElementImpl element =
424
387
new FunctionElementImpl .forOffset (node.beginToken.offset);
@@ -434,12 +397,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
434
397
if (body.isGenerator) {
435
398
element.generator = true ;
436
399
}
437
- if (_inFunction) {
438
- Block enclosingBlock = node.getAncestor ((node) => node is Block );
439
- if (enclosingBlock != null ) {
440
- element.setVisibleRange (enclosingBlock.offset, enclosingBlock.length);
441
- }
442
- }
443
400
element.type = new FunctionTypeImpl (element);
444
401
element.hasImplicitReturnType = true ;
445
402
_currentHolder.addFunction (element);
@@ -490,13 +447,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
490
447
Object visitMethodDeclaration (MethodDeclaration node) {
491
448
try {
492
449
ElementHolder holder = new ElementHolder ();
493
- bool wasInFunction = _inFunction;
494
- _inFunction = true ;
495
- try {
496
- _visitChildren (holder, node);
497
- } finally {
498
- _inFunction = wasInFunction;
499
- }
450
+ _visitChildren (holder, node);
500
451
bool isStatic = node.isStatic;
501
452
Token property = node.propertyKeyword;
502
453
FunctionBody body = node.body;
@@ -726,10 +677,8 @@ class ApiElementBuilder extends _BaseElementBuilder {
726
677
}
727
678
728
679
/**
729
- * Build the table mapping field names to field elements for the fields defined in the current
730
- * class.
731
- *
732
- * @param fields the field elements defined in the current class
680
+ * Build the table mapping field names to field elements for the [fields]
681
+ * defined in the current class.
733
682
*/
734
683
void _buildFieldMap (List <FieldElement > fields) {
735
684
_fieldMap = new HashMap <String , FieldElement >();
0 commit comments