| 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 engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 10205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10216 * | 10216 * |
| 10217 * @param definedNames the mapping table to which the public names are to be a
dded | 10217 * @param definedNames the mapping table to which the public names are to be a
dded |
| 10218 * @param compilationUnit the compilation unit defining the top-level names to
be added to this | 10218 * @param compilationUnit the compilation unit defining the top-level names to
be added to this |
| 10219 * namespace | 10219 * namespace |
| 10220 */ | 10220 */ |
| 10221 void _addPublicNames(Map<String, Element> definedNames, | 10221 void _addPublicNames(Map<String, Element> definedNames, |
| 10222 CompilationUnitElement compilationUnit) { | 10222 CompilationUnitElement compilationUnit) { |
| 10223 for (PropertyAccessorElement element in compilationUnit.accessors) { | 10223 for (PropertyAccessorElement element in compilationUnit.accessors) { |
| 10224 _addIfPublic(definedNames, element); | 10224 _addIfPublic(definedNames, element); |
| 10225 } | 10225 } |
| 10226 for (ClassElement element in compilationUnit.enums) { |
| 10227 _addIfPublic(definedNames, element); |
| 10228 } |
| 10226 for (FunctionElement element in compilationUnit.functions) { | 10229 for (FunctionElement element in compilationUnit.functions) { |
| 10227 _addIfPublic(definedNames, element); | 10230 _addIfPublic(definedNames, element); |
| 10228 } | 10231 } |
| 10229 for (FunctionTypeAliasElement element in | 10232 for (FunctionTypeAliasElement element in |
| 10230 compilationUnit.functionTypeAliases) { | 10233 compilationUnit.functionTypeAliases) { |
| 10231 _addIfPublic(definedNames, element); | 10234 _addIfPublic(definedNames, element); |
| 10232 } | 10235 } |
| 10233 for (ClassElement element in compilationUnit.types) { | 10236 for (ClassElement element in compilationUnit.types) { |
| 10234 _addIfPublic(definedNames, element); | 10237 _addIfPublic(definedNames, element); |
| 10235 } | 10238 } |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11335 if (kind == ElementKind.LOCAL_VARIABLE) { | 11338 if (kind == ElementKind.LOCAL_VARIABLE) { |
| 11336 return element as VariableElement; | 11339 return element as VariableElement; |
| 11337 } | 11340 } |
| 11338 if (kind == ElementKind.PARAMETER) { | 11341 if (kind == ElementKind.PARAMETER) { |
| 11339 return element as VariableElement; | 11342 return element as VariableElement; |
| 11340 } | 11343 } |
| 11341 return null; | 11344 return null; |
| 11342 } | 11345 } |
| 11343 | 11346 |
| 11344 /** | 11347 /** |
| 11348 * Prepares this [ResolverVisitor] to using it for incremental resolution. |
| 11349 */ |
| 11350 void initForIncrementalResolution() { |
| 11351 _overrideManager.enterScope(); |
| 11352 } |
| 11353 |
| 11354 /** |
| 11345 * If it is appropriate to do so, override the current type of the static and
propagated elements | 11355 * If it is appropriate to do so, override the current type of the static and
propagated elements |
| 11346 * associated with the given expression with the given type. Generally speakin
g, it is appropriate | 11356 * associated with the given expression with the given type. Generally speakin
g, it is appropriate |
| 11347 * if the given type is more specific than the current type. | 11357 * if the given type is more specific than the current type. |
| 11348 * | 11358 * |
| 11349 * @param expression the expression used to access the static and propagated e
lements whose types | 11359 * @param expression the expression used to access the static and propagated e
lements whose types |
| 11350 * might be overridden | 11360 * might be overridden |
| 11351 * @param potentialType the potential type of the elements | 11361 * @param potentialType the potential type of the elements |
| 11352 * @param allowPrecisionLoss see @{code overrideVariable} docs | 11362 * @param allowPrecisionLoss see @{code overrideVariable} docs |
| 11353 */ | 11363 */ |
| 11354 void overrideExpression(Expression expression, DartType potentialType, | 11364 void overrideExpression(Expression expression, DartType potentialType, |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11581 Object visitCommentReference(CommentReference node) { | 11591 Object visitCommentReference(CommentReference node) { |
| 11582 // | 11592 // |
| 11583 // We do not visit the identifier because it needs to be visited in the | 11593 // We do not visit the identifier because it needs to be visited in the |
| 11584 // context of the reference. | 11594 // context of the reference. |
| 11585 // | 11595 // |
| 11586 node.accept(_elementResolver); | 11596 node.accept(_elementResolver); |
| 11587 node.accept(_typeAnalyzer); | 11597 node.accept(_typeAnalyzer); |
| 11588 return null; | 11598 return null; |
| 11589 } | 11599 } |
| 11590 | 11600 |
| 11591 /** | |
| 11592 * Prepares this [ResolverVisitor] to using it for incremental resolution. | |
| 11593 */ | |
| 11594 void initForIncrementalResolution() { | |
| 11595 _overrideManager.enterScope(); | |
| 11596 } | |
| 11597 | |
| 11598 @override | 11601 @override |
| 11599 Object visitCompilationUnit(CompilationUnit node) { | 11602 Object visitCompilationUnit(CompilationUnit node) { |
| 11600 // | 11603 // |
| 11601 // TODO(brianwilkerson) The goal of the code below is to visit the | 11604 // TODO(brianwilkerson) The goal of the code below is to visit the |
| 11602 // declarations in such an order that we can infer type information for | 11605 // declarations in such an order that we can infer type information for |
| 11603 // top-level variables before we visit references to them. This is better | 11606 // top-level variables before we visit references to them. This is better |
| 11604 // than making no effort, but still doesn't completely satisfy that goal | 11607 // than making no effort, but still doesn't completely satisfy that goal |
| 11605 // (consider for example "final var a = b; final var b = 0;"; we'll infer a | 11608 // (consider for example "final var a = b; final var b = 0;"; we'll infer a |
| 11606 // type of 'int' for 'b', but not for 'a' because of the order of the | 11609 // type of 'int' for 'b', but not for 'a' because of the order of the |
| 11607 // visits). Ideally we would create a dependency graph, but that would | 11610 // visits). Ideally we would create a dependency graph, but that would |
| (...skipping 4773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16381 * library. | 16384 * library. |
| 16382 */ | 16385 */ |
| 16383 final HashSet<String> members = new HashSet<String>(); | 16386 final HashSet<String> members = new HashSet<String>(); |
| 16384 | 16387 |
| 16385 /** | 16388 /** |
| 16386 * Names of resolved or unresolved class members that are read in the | 16389 * Names of resolved or unresolved class members that are read in the |
| 16387 * library. | 16390 * library. |
| 16388 */ | 16391 */ |
| 16389 final HashSet<String> readMembers = new HashSet<String>(); | 16392 final HashSet<String> readMembers = new HashSet<String>(); |
| 16390 } | 16393 } |
| OLD | NEW |