| 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 869d7e0e25b4302c00d727cfe5e48d5060fbe7ae..e75079841dbfefcfcf7cca62baa3a5ecad2260b4 100644
|
| --- a/pkg/analyzer/test/generated/declaration_resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/declaration_resolver_test.dart
|
| @@ -101,6 +101,33 @@ class DeclarationResolverMetadataTest extends ResolverTestCase {
|
| checkMetadata('export');
|
| }
|
|
|
| + void test_metadata_exportDirective_resynthesized() {
|
| + CompilationUnit unit = resolveSource(r'''
|
| +@a
|
| +export "dart:async";
|
| +
|
| +@b
|
| +export "dart:math";
|
| +
|
| +const a = null;
|
| +const b = null;
|
| +''');
|
| + expect(unit.directives[0].metadata.single.name.name, 'a');
|
| + expect(unit.directives[1].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[0].offset, []);
|
| + unitElement.setAnnotations(unit.directives[1].offset, []);
|
| + expect(unitElement.library.exports[0].metadata, hasLength(1));
|
| + expect(unitElement.library.exports[1].metadata, hasLength(1));
|
| + // DeclarationResolver on the clone should succeed.
|
| + CompilationUnit clonedUnit = AstCloner.clone(unit);
|
| + new DeclarationResolver().resolve(clonedUnit, unit.element);
|
| + expect(unit.directives[0].metadata.single.name.name, 'a');
|
| + expect(unit.directives[1].metadata.single.name.name, 'b');
|
| + }
|
| +
|
| void test_metadata_fieldDeclaration() {
|
| setupCode('class C { @a int x; }');
|
| checkMetadata('x');
|
| @@ -163,6 +190,33 @@ class DeclarationResolverMetadataTest extends ResolverTestCase {
|
| checkMetadata('import');
|
| }
|
|
|
| + void test_metadata_importDirective_resynthesized() {
|
| + CompilationUnit unit = resolveSource(r'''
|
| +@a
|
| +import "dart:async";
|
| +
|
| +@b
|
| +import "dart:math";
|
| +
|
| +const a = null;
|
| +const b = null;
|
| +''');
|
| + expect(unit.directives[0].metadata.single.name.name, 'a');
|
| + expect(unit.directives[1].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[0].offset, []);
|
| + unitElement.setAnnotations(unit.directives[1].offset, []);
|
| + expect(unitElement.library.imports[0].metadata, hasLength(1));
|
| + expect(unitElement.library.imports[1].metadata, hasLength(1));
|
| + // DeclarationResolver on the clone should succeed.
|
| + CompilationUnit clonedUnit = AstCloner.clone(unit);
|
| + new DeclarationResolver().resolve(clonedUnit, unit.element);
|
| + expect(unit.directives[0].metadata.single.name.name, 'a');
|
| + expect(unit.directives[1].metadata.single.name.name, 'b');
|
| + }
|
| +
|
| void test_metadata_libraryDirective() {
|
| setupCode('@a library L;');
|
| checkMetadata('L');
|
|
|