| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 | 2 |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; |
| 7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 4430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4441 int _asIntInRange(Expression expr, int low, int high) { | 4441 int _asIntInRange(Expression expr, int low, int high) { |
| 4442 expr = expr.unParenthesized; | 4442 expr = expr.unParenthesized; |
| 4443 if (expr is IntegerLiteral) { | 4443 if (expr is IntegerLiteral) { |
| 4444 if (expr.value >= low && expr.value <= high) return expr.value; | 4444 if (expr.value >= low && expr.value <= high) return expr.value; |
| 4445 return null; | 4445 return null; |
| 4446 } | 4446 } |
| 4447 int finishIdentifier(SimpleIdentifier identifier) { | 4447 int finishIdentifier(SimpleIdentifier identifier) { |
| 4448 Element staticElement = identifier.staticElement; | 4448 Element staticElement = identifier.staticElement; |
| 4449 if (staticElement is PropertyAccessorElement && staticElement.isGetter) { | 4449 if (staticElement is PropertyAccessorElement && staticElement.isGetter) { |
| 4450 PropertyInducingElement variable = staticElement.variable; | 4450 PropertyInducingElement variable = staticElement.variable; |
| 4451 int value = variable?.constantValue?.toIntValue(); | 4451 int value = variable?.computeConstantValue()?.toIntValue(); |
| 4452 if (value != null && value >= low && value <= high) return value; | 4452 if (value != null && value >= low && value <= high) return value; |
| 4453 } | 4453 } |
| 4454 return null; | 4454 return null; |
| 4455 } | 4455 } |
| 4456 | 4456 |
| 4457 if (expr is SimpleIdentifier) { | 4457 if (expr is SimpleIdentifier) { |
| 4458 return finishIdentifier(expr); | 4458 return finishIdentifier(expr); |
| 4459 } else if (expr is PrefixedIdentifier && !expr.isDeferred) { | 4459 } else if (expr is PrefixedIdentifier && !expr.isDeferred) { |
| 4460 return finishIdentifier(expr.identifier); | 4460 return finishIdentifier(expr.identifier); |
| 4461 } | 4461 } |
| (...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5890 if (targetIdentifier.staticElement is! PrefixElement) return false; | 5890 if (targetIdentifier.staticElement is! PrefixElement) return false; |
| 5891 var prefix = targetIdentifier.staticElement as PrefixElement; | 5891 var prefix = targetIdentifier.staticElement as PrefixElement; |
| 5892 | 5892 |
| 5893 // The library the prefix is referring to must come from a deferred import. | 5893 // The library the prefix is referring to must come from a deferred import. |
| 5894 var containingLibrary = resolutionMap | 5894 var containingLibrary = resolutionMap |
| 5895 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 5895 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) |
| 5896 .library; | 5896 .library; |
| 5897 var imports = containingLibrary.getImportsWithPrefix(prefix); | 5897 var imports = containingLibrary.getImportsWithPrefix(prefix); |
| 5898 return imports.length == 1 && imports[0].isDeferred; | 5898 return imports.length == 1 && imports[0].isDeferred; |
| 5899 } | 5899 } |
| OLD | NEW |