44
55import 'dart:collection' ;
66
7- import 'package:analyzer/dart/ast/ast.dart' ;
8- import 'package:analyzer/dart/ast/visitor.dart' ;
97import 'package:analyzer/dart/element/element.dart' ;
108import 'package:analyzer/dart/element/type.dart' ;
119import 'package:analyzer/src/dart/element/element.dart' ;
@@ -16,19 +14,6 @@ import 'package:analyzer/src/summary/format.dart';
1614import 'package:analyzer/src/summary/idl.dart' ;
1715import '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