OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.test.constant_test; | 5 library analyzer.test.constant_test; |
6 | 6 |
7 import 'package:analyzer/context/declared_variables.dart'; | 7 import 'package:analyzer/context/declared_variables.dart'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/ast/resolution_accessors.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
11 import 'package:analyzer/error/error.dart'; | 12 import 'package:analyzer/error/error.dart'; |
12 import 'package:analyzer/error/listener.dart'; | 13 import 'package:analyzer/error/listener.dart'; |
13 import 'package:analyzer/src/dart/element/element.dart'; | 14 import 'package:analyzer/src/dart/element/element.dart'; |
14 import 'package:analyzer/src/error/codes.dart'; | 15 import 'package:analyzer/src/error/codes.dart'; |
15 import 'package:analyzer/src/generated/constant.dart'; | 16 import 'package:analyzer/src/generated/constant.dart'; |
16 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
17 import 'package:analyzer/src/generated/resolver.dart'; | 18 import 'package:analyzer/src/generated/resolver.dart'; |
18 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 DartObjectImpl _evaluate(Expression expression, ErrorReporter errorReporter) { | 1583 DartObjectImpl _evaluate(Expression expression, ErrorReporter errorReporter) { |
1583 return expression.accept(new ConstantVisitor( | 1584 return expression.accept(new ConstantVisitor( |
1584 new ConstantEvaluationEngine( | 1585 new ConstantEvaluationEngine( |
1585 new TestTypeProvider(), new DeclaredVariables(), | 1586 new TestTypeProvider(), new DeclaredVariables(), |
1586 typeSystem: new TypeSystemImpl()), | 1587 typeSystem: new TypeSystemImpl()), |
1587 errorReporter)); | 1588 errorReporter)); |
1588 } | 1589 } |
1589 | 1590 |
1590 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name, | 1591 DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name, |
1591 Map<String, DartObjectImpl> lexicalEnvironment) { | 1592 Map<String, DartObjectImpl> lexicalEnvironment) { |
1592 Source source = compilationUnit.element.source; | 1593 Source source = elementForCompilationUnit(compilationUnit).source; |
1593 Expression expression = | 1594 Expression expression = |
1594 findTopLevelConstantExpression(compilationUnit, name); | 1595 findTopLevelConstantExpression(compilationUnit, name); |
1595 GatheringErrorListener errorListener = new GatheringErrorListener(); | 1596 GatheringErrorListener errorListener = new GatheringErrorListener(); |
1596 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 1597 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
1597 DartObjectImpl result = expression.accept(new ConstantVisitor( | 1598 DartObjectImpl result = expression.accept(new ConstantVisitor( |
1598 new ConstantEvaluationEngine(typeProvider, new DeclaredVariables(), | 1599 new ConstantEvaluationEngine(typeProvider, new DeclaredVariables(), |
1599 typeSystem: typeSystem), | 1600 typeSystem: typeSystem), |
1600 errorReporter, | 1601 errorReporter, |
1601 lexicalEnvironment: lexicalEnvironment)); | 1602 lexicalEnvironment: lexicalEnvironment)); |
1602 errorListener.assertNoErrors(); | 1603 errorListener.assertNoErrors(); |
1603 return result; | 1604 return result; |
1604 } | 1605 } |
1605 } | 1606 } |
1606 | 1607 |
1607 @reflectiveTest | 1608 @reflectiveTest |
1608 class StrongConstantValueComputerTest extends ConstantValueComputerTest { | 1609 class StrongConstantValueComputerTest extends ConstantValueComputerTest { |
1609 void setUp() { | 1610 void setUp() { |
1610 super.setUp(); | 1611 super.setUp(); |
1611 resetWithOptions(new AnalysisOptionsImpl()..strongMode = true); | 1612 resetWithOptions(new AnalysisOptionsImpl()..strongMode = true); |
1612 } | 1613 } |
1613 } | 1614 } |
OLD | NEW |