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

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

Issue 2662173004: Fix for PartDirective annotations while applying resynthesized element model. (Closed)
Patch Set: Created 3 years, 11 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/generated/declaration_resolver.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/generated/declaration_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/declaration_resolver_test.dart b/pkg/analyzer/test/generated/declaration_resolver_test.dart
index 9ecac6a32d3a4e5af95ec82243f4e9f31e5568d0..3f7071f5c65f8e55fad8454bb6d381d141b736e2 100644
--- a/pkg/analyzer/test/generated/declaration_resolver_test.dart
+++ b/pkg/analyzer/test/generated/declaration_resolver_test.dart
@@ -219,6 +219,38 @@ const b = null;
expect(unit.directives[1].metadata.single.name.name, 'b');
}
+ solo_test_metadata_partDirective_resynthesized() async {
Brian Wilkerson 2017/01/31 19:40:07 Remove "solo_".
+ addNamedSource('/part_a.dart', 'part of L;');
+ addNamedSource('/part_b.dart', 'part of L;');
+
+ CompilationUnit unit = await resolveSource(r'''
+library L;
+
+@a
+part "part_a.dart";
+
+@b
+part "part_b.dart";
+
+const a = null;
+const b = null;
+''');
+ expect(unit.directives[1].metadata.single.name.name, 'a');
+ expect(unit.directives[2].metadata.single.name.name, 'b');
+ var unitElement = unit.element as CompilationUnitElementImpl;
+ // Damage the unit element - as if "setAnnotations" were not called.
+ // The ImportElement(s) still have the metadata, we should use it.
+ unitElement.setAnnotations(unit.directives[1].offset, []);
+ unitElement.setAnnotations(unit.directives[2].offset, []);
+ expect(unitElement.library.parts[0].metadata, hasLength(1));
+ expect(unitElement.library.parts[1].metadata, hasLength(1));
+ // DeclarationResolver on the clone should succeed.
+ CompilationUnit clonedUnit = AstCloner.clone(unit);
+ new DeclarationResolver().resolve(clonedUnit, unit.element);
+ expect(unit.directives[1].metadata.single.name.name, 'a');
+ expect(unit.directives[2].metadata.single.name.name, 'b');
+ }
+
test_metadata_libraryDirective() async {
await setupCode('@a library L;');
checkMetadata('L');
« no previous file with comments | « pkg/analyzer/lib/src/generated/declaration_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698