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

Unified Diff: pkg/analyzer/test/src/task/incremental_element_builder_test.dart

Issue 2160673002: Another fix incremental constants - annotations should use the old unit element. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/incremental_element_builder_test.dart
diff --git a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
index 3761bb6e431c85d67d017a0a4587f53efb03943c..99bc6aad11c6f00df2b03fc59b9913c58cfbe20b 100644
--- a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
+++ b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
@@ -1649,6 +1649,18 @@ class A {
''');
}
+ test_update_annotation_add() {
+ _buildOldUnit(r'''
+const myAnnotation = const Object();
+foo() {}
+''');
+ _buildNewUnit(r'''
+const myAnnotation = const Object();
+@myAnnotation
+foo() {}
+''');
+ }
+
test_update_beforeClassWithDelta_nameOffset() {
_buildOldUnit(r'''
class A {}
@@ -1866,6 +1878,16 @@ class _BuiltElementsValidator extends AstComparator {
actual.getAncestor((n) => n is ClassDeclaration);
expect(element.enclosingElement, same(classNode.element));
}
+ // ElementAnnotationImpl must use the enclosing CompilationUnitElement.
+ if (actual is Annotation) {
+ AstNode parent = actual.parent;
+ if (parent is Declaration) {
+ ElementAnnotationImpl actualElement = actual.elementAnnotation;
+ CompilationUnitElement enclosingUnitElement =
+ parent.element.getAncestor((a) => a is CompilationUnitElement);
+ expect(actualElement.compilationUnit, same(enclosingUnitElement));
+ }
+ }
// Identifiers like 'a.b' in 'new a.b()' might be rewritten if resolver
// sees that 'a' is actually a class name, so 'b' is a constructor name.
//
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698