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

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

Issue 2748763003: Add support for parsing annotations with Fasta. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/parser_test.dart
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index bdc478523abe6f536dcb093a6f856a4307fd6eb8..68fc5a672a8f88892e3c17b3ec56df29c4f944cc 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -13412,6 +13412,56 @@ abstract class TopLevelParserTestMixin implements AbstractParserTestCase {
expectCommentText(classDeclaration.documentationComment, '/// Doc');
}
+ void test_parseClassDeclaration_metadata() {
+ createParser('@A @B(2) @C.foo(3) @d.E.bar(4, 5) class X {}');
+ var declaration = parseFullCompilationUnitMember() as ClassDeclaration;
+ expect(declaration.metadata, hasLength(4));
+
+ {
+ var annotation = declaration.metadata[0];
+ expect(annotation.atSign, isNotNull);
+ expect(annotation.name, new isInstanceOf<SimpleIdentifier>());
+ expect(annotation.name.name, 'A');
+ expect(annotation.period, isNull);
+ expect(annotation.constructorName, isNull);
+ expect(annotation.arguments, isNull);
+ }
+
+ {
+ var annotation = declaration.metadata[1];
+ expect(annotation.atSign, isNotNull);
+ expect(annotation.name, new isInstanceOf<SimpleIdentifier>());
+ expect(annotation.name.name, 'B');
+ expect(annotation.period, isNull);
+ expect(annotation.constructorName, isNull);
+ expect(annotation.arguments, isNotNull);
+ expect(annotation.arguments.arguments, hasLength(1));
+ }
+
+ {
+ var annotation = declaration.metadata[2];
+ expect(annotation.atSign, isNotNull);
+ expect(annotation.name, new isInstanceOf<PrefixedIdentifier>());
+ expect(annotation.name.name, 'C.foo');
+ expect(annotation.period, isNull);
+ expect(annotation.constructorName, isNull);
+ expect(annotation.arguments, isNotNull);
+ expect(annotation.arguments.arguments, hasLength(1));
+ }
+
+ {
+ var annotation = declaration.metadata[3];
+ expect(annotation.atSign, isNotNull);
+ expect(annotation.name, new isInstanceOf<PrefixedIdentifier>());
+ expect(annotation.name.name, 'd.E');
+ expect(annotation.period, isNotNull);
+ expect(annotation.constructorName, isNotNull);
+ expect(annotation.constructorName.name, 'bar');
+ expect(annotation.arguments, isNotNull);
+ expect(annotation.arguments.arguments, hasLength(2));
+ }
+ }
+
void test_parseClassTypeAlias_withDocumentationComment() {
createParser('/// Doc\nclass C = D with E;');
var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias;
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698