| OLD | NEW | 
|---|
| 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 library analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; | 
| 6 | 6 | 
| 7 import 'dart:collection'; | 7 import 'dart:collection'; | 
| 8 | 8 | 
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; | 
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; | 
| (...skipping 5184 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5195 class PartialResolverVisitor extends ResolverVisitor { | 5195 class PartialResolverVisitor extends ResolverVisitor { | 
| 5196   /** | 5196   /** | 
| 5197    * The static variables and fields that have an initializer. These are the | 5197    * The static variables and fields that have an initializer. These are the | 
| 5198    * variables that need to be re-resolved after static variables have their | 5198    * variables that need to be re-resolved after static variables have their | 
| 5199    * types inferred. A subset of these variables are those whose types should | 5199    * types inferred. A subset of these variables are those whose types should | 
| 5200    * be inferred. | 5200    * be inferred. | 
| 5201    */ | 5201    */ | 
| 5202   final List<VariableElement> staticVariables = <VariableElement>[]; | 5202   final List<VariableElement> staticVariables = <VariableElement>[]; | 
| 5203 | 5203 | 
| 5204   /** | 5204   /** | 
| 5205    * The static and instance variables and fields that have an initializer. |  | 
| 5206    * These are the variables whose types might be propagated. |  | 
| 5207    */ |  | 
| 5208   final List<VariableElement> propagableVariables = <VariableElement>[]; |  | 
| 5209 |  | 
| 5210   /** |  | 
| 5211    * Initialize a newly created visitor to resolve the nodes in an AST node. | 5205    * Initialize a newly created visitor to resolve the nodes in an AST node. | 
| 5212    * | 5206    * | 
| 5213    * The [definingLibrary] is the element for the library containing the node | 5207    * The [definingLibrary] is the element for the library containing the node | 
| 5214    * being visited. The [source] is the source representing the compilation unit | 5208    * being visited. The [source] is the source representing the compilation unit | 
| 5215    * containing the node being visited. The [typeProvider] is the object used to | 5209    * containing the node being visited. The [typeProvider] is the object used to | 
| 5216    * access the types from the core library. The [errorListener] is the error | 5210    * access the types from the core library. The [errorListener] is the error | 
| 5217    * listener that will be informed of any errors that are found during | 5211    * listener that will be informed of any errors that are found during | 
| 5218    * resolution. The [nameScope] is the scope used to resolve identifiers in the | 5212    * resolution. The [nameScope] is the scope used to resolve identifiers in the | 
| 5219    * node that will first be visited.  If `null` or unspecified, a new | 5213    * node that will first be visited.  If `null` or unspecified, a new | 
| 5220    * [LibraryScope] will be created based on [definingLibrary] and | 5214    * [LibraryScope] will be created based on [definingLibrary] and | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 5241   @override | 5235   @override | 
| 5242   Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 5236   Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 
| 5243     if (_shouldBeSkipped(node)) { | 5237     if (_shouldBeSkipped(node)) { | 
| 5244       return null; | 5238       return null; | 
| 5245     } | 5239     } | 
| 5246     return super.visitExpressionFunctionBody(node); | 5240     return super.visitExpressionFunctionBody(node); | 
| 5247   } | 5241   } | 
| 5248 | 5242 | 
| 5249   @override | 5243   @override | 
| 5250   Object visitFieldDeclaration(FieldDeclaration node) { | 5244   Object visitFieldDeclaration(FieldDeclaration node) { | 
| 5251     _addPropagableVariables(node.fields.variables); |  | 
| 5252     if (node.isStatic) { | 5245     if (node.isStatic) { | 
| 5253       _addStaticVariables(node.fields.variables); | 5246       _addStaticVariables(node.fields.variables); | 
| 5254     } | 5247     } | 
| 5255     return super.visitFieldDeclaration(node); | 5248     return super.visitFieldDeclaration(node); | 
| 5256   } | 5249   } | 
| 5257 | 5250 | 
| 5258   @override | 5251   @override | 
| 5259   Object visitNode(AstNode node) { | 5252   Object visitNode(AstNode node) { | 
| 5260     return super.visitNode(node); | 5253     return super.visitNode(node); | 
| 5261   } | 5254   } | 
| 5262 | 5255 | 
| 5263   @override | 5256   @override | 
| 5264   Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 5257   Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 
| 5265     _addPropagableVariables(node.variables.variables); |  | 
| 5266     _addStaticVariables(node.variables.variables); | 5258     _addStaticVariables(node.variables.variables); | 
| 5267     return super.visitTopLevelVariableDeclaration(node); | 5259     return super.visitTopLevelVariableDeclaration(node); | 
| 5268   } | 5260   } | 
| 5269 | 5261 | 
| 5270   /** | 5262   /** | 
| 5271    * Add all of the [variables] with initializers to [propagableVariables]. |  | 
| 5272    */ |  | 
| 5273   void _addPropagableVariables(List<VariableDeclaration> variables) { |  | 
| 5274     int length = variables.length; |  | 
| 5275     for (int i = 0; i < length; i++) { |  | 
| 5276       VariableDeclaration variable = variables[i]; |  | 
| 5277       if (variable.name.name.isNotEmpty && variable.initializer != null) { |  | 
| 5278         VariableElement element = variable.element; |  | 
| 5279         if (element.isConst || element.isFinal) { |  | 
| 5280           propagableVariables.add(element); |  | 
| 5281         } |  | 
| 5282       } |  | 
| 5283     } |  | 
| 5284   } |  | 
| 5285 |  | 
| 5286   /** |  | 
| 5287    * Add all of the [variables] with initializers to the list of variables whose | 5263    * Add all of the [variables] with initializers to the list of variables whose | 
| 5288    * type can be inferred. Technically, we only infer the types of variables | 5264    * type can be inferred. Technically, we only infer the types of variables | 
| 5289    * that do not have a static type, but all variables with initializers | 5265    * that do not have a static type, but all variables with initializers | 
| 5290    * potentially need to be re-resolved after inference because they might | 5266    * potentially need to be re-resolved after inference because they might | 
| 5291    * refer to a field whose type was inferred. | 5267    * refer to a field whose type was inferred. | 
| 5292    */ | 5268    */ | 
| 5293   void _addStaticVariables(List<VariableDeclaration> variables) { | 5269   void _addStaticVariables(List<VariableDeclaration> variables) { | 
| 5294     int length = variables.length; | 5270     int length = variables.length; | 
| 5295     for (int i = 0; i < length; i++) { | 5271     for (int i = 0; i < length; i++) { | 
| 5296       VariableDeclaration variable = variables[i]; | 5272       VariableDeclaration variable = variables[i]; | 
| (...skipping 5874 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 11171       return null; | 11147       return null; | 
| 11172     } | 11148     } | 
| 11173     if (identical(node.staticElement, variable)) { | 11149     if (identical(node.staticElement, variable)) { | 
| 11174       if (node.inSetterContext()) { | 11150       if (node.inSetterContext()) { | 
| 11175         result = true; | 11151         result = true; | 
| 11176       } | 11152       } | 
| 11177     } | 11153     } | 
| 11178     return null; | 11154     return null; | 
| 11179   } | 11155   } | 
| 11180 } | 11156 } | 
| OLD | NEW | 
|---|