Skip to content

Commit c3cd6b0

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Remove VariableGatherer and related.
Change-Id: I4c2982e14f09c4876765cc70fc47c0261eaf24b2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122304 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent de63b83 commit c3cd6b0

File tree

1 file changed

+4
-60
lines changed

1 file changed

+4
-60
lines changed

pkg/analyzer/lib/src/task/strong_mode.dart

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import 'dart:collection';
66

7-
import 'package:analyzer/dart/ast/ast.dart';
8-
import 'package:analyzer/dart/ast/visitor.dart';
97
import 'package:analyzer/dart/element/element.dart';
108
import 'package:analyzer/dart/element/type.dart';
119
import 'package:analyzer/src/dart/element/element.dart';
@@ -16,19 +14,6 @@ import 'package:analyzer/src/summary/format.dart';
1614
import 'package:analyzer/src/summary/idl.dart';
1715
import 'package:analyzer/src/summary2/lazy_ast.dart';
1816

19-
/**
20-
* Sets the type of the field. The types in implicit accessors are updated
21-
* implicitly, and the types of explicit accessors should be updated separately.
22-
*/
23-
void setFieldType(VariableElement field, DartType newType) {
24-
(field as VariableElementImpl).type = newType;
25-
}
26-
27-
/**
28-
* A function that returns `true` if the given [element] passes the filter.
29-
*/
30-
typedef bool VariableFilter(VariableElement element);
31-
3217
/**
3318
* An object used to infer the type of instance fields and the return types of
3419
* instance methods within a single compilation unit.
@@ -258,7 +243,7 @@ class InstanceMemberInferrer {
258243
parameter.inheritsCovariant = typeResult.isCovariant;
259244
}
260245
}
261-
setFieldType(element.variable, typeResult.type);
246+
(element.variable as FieldElementImpl).type = typeResult.type;
262247
}
263248

264249
/**
@@ -396,15 +381,15 @@ class InstanceMemberInferrer {
396381
* If the given [field] represents a non-synthetic instance field for
397382
* which no type was provided, infer the type of the field.
398383
*/
399-
void _inferField(FieldElement field) {
384+
void _inferField(FieldElementImpl field) {
400385
if (field.isSynthetic || field.isStatic) {
401386
return;
402387
}
403388

404389
_FieldOverrideInferenceResult typeResult =
405390
_computeFieldOverrideType(field.getter);
406391
if (typeResult.isError) {
407-
if (field is FieldElementImpl && field.linkedNode != null) {
392+
if (field.linkedNode != null) {
408393
LazyAst.setTypeInferenceError(
409394
field.linkedNode,
410395
TopLevelInferenceErrorBuilder(
@@ -429,7 +414,7 @@ class InstanceMemberInferrer {
429414
newType = typeProvider.dynamicType;
430415
}
431416

432-
setFieldType(field, newType);
417+
field.type = newType;
433418
}
434419

435420
if (field.setter != null) {
@@ -537,47 +522,6 @@ class InstanceMemberInferrer {
537522
}
538523
}
539524

540-
/**
541-
* A visitor that will gather all of the variables referenced within a given
542-
* AST structure. The collection can be restricted to contain only those
543-
* variables that pass a specified filter.
544-
*/
545-
class VariableGatherer extends RecursiveAstVisitor {
546-
/**
547-
* The filter used to limit which variables are gathered, or `null` if no
548-
* filtering is to be performed.
549-
*/
550-
final VariableFilter filter;
551-
552-
/**
553-
* The variables that were found.
554-
*/
555-
final Set<VariableElement> results = new HashSet<VariableElement>();
556-
557-
/**
558-
* Initialize a newly created gatherer to gather all of the variables that
559-
* pass the given [filter] (or all variables if no filter is provided).
560-
*/
561-
VariableGatherer([this.filter]);
562-
563-
@override
564-
void visitSimpleIdentifier(SimpleIdentifier node) {
565-
if (!node.inDeclarationContext()) {
566-
Element nonAccessor(Element element) {
567-
if (element is PropertyAccessorElement && element.isSynthetic) {
568-
return element.variable;
569-
}
570-
return element;
571-
}
572-
573-
Element element = nonAccessor(node.staticElement);
574-
if (element is VariableElement && (filter == null || filter(element))) {
575-
results.add(element);
576-
}
577-
}
578-
}
579-
}
580-
581525
/**
582526
* A class of exception that is not used anywhere else.
583527
*/

0 commit comments

Comments
 (0)