Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Unified Diff: pkg/analyzer/test/generated/constant_test.dart

Issue 1665353002: Use ElementAnnotation as the ConstantEvaluationTarget for annotations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/constant_test.dart
diff --git a/pkg/analyzer/test/generated/constant_test.dart b/pkg/analyzer/test/generated/constant_test.dart
index f82c31edbc596329840ee2df488b46c4857da10d..4b611b7a817268b1bbe0d3cadf2cfdd722e73070 100644
--- a/pkg/analyzer/test/generated/constant_test.dart
+++ b/pkg/analyzer/test/generated/constant_test.dart
@@ -499,7 +499,14 @@ class ConstantFinderTest {
* represents a reference to a compile-time constant variable).
*/
void test_visitAnnotation_constantVariable() {
- _node = AstFactory.annotation(AstFactory.identifier3('x'));
+ CompilationUnitElement compilationUnitElement =
+ ElementFactory.compilationUnit('/test.dart', _source)..source = _source;
+ ElementFactory.library(_context, 'L').definingCompilationUnit =
+ compilationUnitElement;
+ ElementAnnotationImpl elementAnnotation =
+ new ElementAnnotationImpl(compilationUnitElement);
+ _node = elementAnnotation.annotationAst = AstFactory.annotation(
+ AstFactory.identifier3('x'))..elementAnnotation = elementAnnotation;
expect(_findAnnotations(), contains(_node));
}
@@ -508,11 +515,27 @@ class ConstantFinderTest {
* constructor.
*/
void test_visitAnnotation_invocation() {
- _node = AstFactory.annotation2(
- AstFactory.identifier3('A'), null, AstFactory.argumentList());
+ CompilationUnitElement compilationUnitElement =
+ ElementFactory.compilationUnit('/test.dart', _source)..source = _source;
+ ElementFactory.library(_context, 'L').definingCompilationUnit =
+ compilationUnitElement;
+ ElementAnnotationImpl elementAnnotation =
+ new ElementAnnotationImpl(compilationUnitElement);
+ _node = elementAnnotation.annotationAst = AstFactory.annotation2(
+ AstFactory.identifier3('A'), null, AstFactory.argumentList())
+ ..elementAnnotation = elementAnnotation;
expect(_findAnnotations(), contains(_node));
}
+ void test_visitAnnotation_partOf() {
+ // Analyzer ignores annotations on "part of" directives.
+ Annotation annotation = AstFactory.annotation2(
+ AstFactory.identifier3('A'), null, AstFactory.argumentList());
+ _node = AstFactory.partOfDirective2(
+ <Annotation>[annotation], AstFactory.libraryIdentifier2(<String>['L']));
+ expect(_findConstants(), isEmpty);
+ }
+
void test_visitConstructorDeclaration_const() {
ConstructorElement element = _setupConstructorDeclaration("A", true);
expect(_findConstants(), contains(element));
@@ -590,10 +613,10 @@ class ConstantFinderTest {
List<Annotation> _findAnnotations() {
Set<Annotation> annotations = new Set<Annotation>();
for (ConstantEvaluationTarget target in _findConstants()) {
- if (target is ConstantEvaluationTarget_Annotation) {
+ if (target is ElementAnnotationImpl) {
expect(target.context, same(_context));
expect(target.source, same(_source));
- annotations.add(target.annotation);
+ annotations.add(target.annotationAst);
}
}
return new List<Annotation>.from(annotations);
@@ -1824,6 +1847,7 @@ const A a = const A();
}
int _assertValidInt(EvaluationResultImpl result) {
+ expect(result, isNotNull);
expect(result.value, isNotNull);
DartObjectImpl value = result.value;
expect(value.type, typeProvider.intType);
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698