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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.parser_test; 5 library analyzer.test.generated.parser_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 13394 matching lines...) Expand 10 before | Expand all | Expand 10 after
13405 expect(declaration.typeParameters.typeParameters, hasLength(1)); 13405 expect(declaration.typeParameters.typeParameters, hasLength(1));
13406 _assertIsDeclarationName(declaration.typeParameters.typeParameters[0].name); 13406 _assertIsDeclarationName(declaration.typeParameters.typeParameters[0].name);
13407 } 13407 }
13408 13408
13409 void test_parseClassDeclaration_withDocumentationComment() { 13409 void test_parseClassDeclaration_withDocumentationComment() {
13410 createParser('/// Doc\nclass C {}'); 13410 createParser('/// Doc\nclass C {}');
13411 var classDeclaration = parseFullCompilationUnitMember() as ClassDeclaration; 13411 var classDeclaration = parseFullCompilationUnitMember() as ClassDeclaration;
13412 expectCommentText(classDeclaration.documentationComment, '/// Doc'); 13412 expectCommentText(classDeclaration.documentationComment, '/// Doc');
13413 } 13413 }
13414 13414
13415 void test_parseClassDeclaration_metadata() {
13416 createParser('@A @B(2) @C.foo(3) @d.E.bar(4, 5) class X {}');
13417 var declaration = parseFullCompilationUnitMember() as ClassDeclaration;
13418 expect(declaration.metadata, hasLength(4));
13419
13420 {
13421 var annotation = declaration.metadata[0];
13422 expect(annotation.atSign, isNotNull);
13423 expect(annotation.name, new isInstanceOf<SimpleIdentifier>());
13424 expect(annotation.name.name, 'A');
13425 expect(annotation.period, isNull);
13426 expect(annotation.constructorName, isNull);
13427 expect(annotation.arguments, isNull);
13428 }
13429
13430 {
13431 var annotation = declaration.metadata[1];
13432 expect(annotation.atSign, isNotNull);
13433 expect(annotation.name, new isInstanceOf<SimpleIdentifier>());
13434 expect(annotation.name.name, 'B');
13435 expect(annotation.period, isNull);
13436 expect(annotation.constructorName, isNull);
13437 expect(annotation.arguments, isNotNull);
13438 expect(annotation.arguments.arguments, hasLength(1));
13439 }
13440
13441 {
13442 var annotation = declaration.metadata[2];
13443 expect(annotation.atSign, isNotNull);
13444 expect(annotation.name, new isInstanceOf<PrefixedIdentifier>());
13445 expect(annotation.name.name, 'C.foo');
13446 expect(annotation.period, isNull);
13447 expect(annotation.constructorName, isNull);
13448 expect(annotation.arguments, isNotNull);
13449 expect(annotation.arguments.arguments, hasLength(1));
13450 }
13451
13452 {
13453 var annotation = declaration.metadata[3];
13454 expect(annotation.atSign, isNotNull);
13455 expect(annotation.name, new isInstanceOf<PrefixedIdentifier>());
13456 expect(annotation.name.name, 'd.E');
13457 expect(annotation.period, isNotNull);
13458 expect(annotation.constructorName, isNotNull);
13459 expect(annotation.constructorName.name, 'bar');
13460 expect(annotation.arguments, isNotNull);
13461 expect(annotation.arguments.arguments, hasLength(2));
13462 }
13463 }
13464
13415 void test_parseClassTypeAlias_withDocumentationComment() { 13465 void test_parseClassTypeAlias_withDocumentationComment() {
13416 createParser('/// Doc\nclass C = D with E;'); 13466 createParser('/// Doc\nclass C = D with E;');
13417 var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias; 13467 var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias;
13418 expectCommentText(classTypeAlias.documentationComment, '/// Doc'); 13468 expectCommentText(classTypeAlias.documentationComment, '/// Doc');
13419 } 13469 }
13420 13470
13421 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { 13471 void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
13422 createParser('abstract<dynamic> _abstract = new abstract.A();'); 13472 createParser('abstract<dynamic> _abstract = new abstract.A();');
13423 CompilationUnit unit = parser.parseCompilationUnit2(); 13473 CompilationUnit unit = parser.parseCompilationUnit2();
13424 expect(unit, isNotNull); 13474 expect(unit, isNotNull);
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
14833 expectCommentText(typeAlias.documentationComment, '/// Doc'); 14883 expectCommentText(typeAlias.documentationComment, '/// Doc');
14834 } 14884 }
14835 14885
14836 /** 14886 /**
14837 * Assert that the given [name] is in declaration context. 14887 * Assert that the given [name] is in declaration context.
14838 */ 14888 */
14839 void _assertIsDeclarationName(SimpleIdentifier name) { 14889 void _assertIsDeclarationName(SimpleIdentifier name) {
14840 expect(name.inDeclarationContext(), isTrue); 14890 expect(name.inDeclarationContext(), isTrue);
14841 } 14891 }
14842 } 14892 }
OLDNEW
« 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