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

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

Issue 1660713002: Create ElementAnnotation objects prior to resolution. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix accidental comment change Created 4 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/test/generated/resolver_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/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index e351c39f68421478b60cbed0bc30936a683307f8..a38d81e5f4e4ef7401760f2e1c4a140c2ccc08f9 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -242,6 +242,18 @@ class B = Object with A;
@reflectiveTest
class BuildDirectiveElementsTaskTest extends _AbstractDartTaskTest {
+ /**
+ * Verify that the given [element] has exactly one annotation, and that its
+ * [ElementAnnotationImpl] is unresolved and points back to [element].
+ */
+ void checkMetadata(Element element) {
+ expect(element.metadata, hasLength(1));
+ expect(element.metadata[0], new isInstanceOf<ElementAnnotationImpl>());
+ ElementAnnotationImpl elementAnnotation = element.metadata[0];
+ expect(elementAnnotation.element, isNull); // Not yet resolved
+ expect(elementAnnotation.annotatedElement, element);
+ }
+
test_perform() {
List<Source> sources = newSources({
'/libA.dart': '''
@@ -469,6 +481,37 @@ library libC;
expect(importElementC.prefix, prefixElement);
}
+ test_perform_metadata() {
+ List<Source> sources = newSources({
+ '/libA.dart': '''
+@a library libA;
+@b import 'libB.dart';
+@c export 'libC.dart';
+@d part 'part.dart';''',
+ '/libB.dart': 'library libB;',
+ '/libC.dart': 'library libC;',
+ '/part.dart': '@e part of libA;'
+ });
+ Source sourceA = sources[0];
+ Source sourceD = sources[3];
+ // perform task
+ computeResult(sourceA, LIBRARY_ELEMENT2,
+ matcher: isBuildDirectiveElementsTask);
+ // Get outputs
+ LibraryElement libraryA =
+ context.getCacheEntry(sourceA).getValue(LIBRARY_ELEMENT2);
+ CompilationUnit part = context
+ .getCacheEntry(new LibrarySpecificUnit(sourceA, sourceD))
+ .getValue(RESOLVED_UNIT1);
+ // Validate metadata
+ checkMetadata(libraryA);
+ checkMetadata(libraryA.imports[0]);
+ checkMetadata(libraryA.exports[0]);
+ checkMetadata(libraryA.parts[0]);
+ expect(part.directives[0], new isInstanceOf<PartOfDirective>());
+ checkMetadata(part.directives[0].element);
+ }
+
void _assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes) {
_fillErrorListener(BUILD_DIRECTIVES_ERRORS);
errorListener.assertErrorsWithCodes(expectedErrorCodes);
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698