Skip to content

Commit 368bcc4

Browse files
danrubelcommit-bot@chromium.org
authored andcommitted
Add parse dartdoc tests for fasta parser
Change-Id: Ieb8ed7d09abdae097f991aae566cd6256b18ef24 Reviewed-on: https://dart-review.googlesource.com/68202 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Dan Rubel <[email protected]>
1 parent cda3659 commit 368bcc4

File tree

2 files changed

+1006
-813
lines changed

2 files changed

+1006
-813
lines changed

pkg/analyzer/test/generated/parser_fasta_test.dart

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:analyzer/dart/ast/token.dart' as analyzer;
77
import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
88
import 'package:analyzer/error/error.dart';
99
import 'package:analyzer/error/listener.dart' show ErrorReporter;
10+
import 'package:analyzer/src/dart/ast/token.dart';
1011
import 'package:analyzer/src/dart/scanner/scanner.dart';
1112
import 'package:analyzer/src/generated/parser.dart' as analyzer;
1213
import 'package:analyzer/src/generated/utilities_dart.dart';
@@ -420,6 +421,22 @@ class FastaParserTestCase extends Object
420421
return cascadeExpression.cascadeSections.first;
421422
}
422423

424+
CommentReference parseCommentReference(
425+
String referenceSource, int sourceOffset) {
426+
String padding = ' '.padLeft(sourceOffset - 4, 'a');
427+
String source = '/**$padding[$referenceSource] */ class C { }';
428+
CompilationUnit unit = parseCompilationUnit(source);
429+
ClassDeclaration clazz = unit.declarations[0];
430+
Comment comment = clazz.documentationComment;
431+
List<CommentReference> references = comment.references;
432+
if (references.isEmpty) {
433+
return null;
434+
} else {
435+
expect(references, hasLength(1));
436+
return references[0];
437+
}
438+
}
439+
423440
@override
424441
CompilationUnit parseCompilationUnit(String content,
425442
{List<ErrorCode> codes, List<ExpectedError> errors}) {
@@ -828,6 +845,22 @@ class ParserProxy extends analyzer.ParserAdapter {
828845
return _run('Import', () => super.parseCombinators());
829846
}
830847

848+
@override
849+
List<CommentReference> parseCommentReferences(
850+
List<DocumentationCommentToken> tokens) {
851+
for (int index = 0; index < tokens.length - 1; ++index) {
852+
analyzer.Token next = tokens[index].next;
853+
if (next == null) {
854+
tokens[index].setNext(tokens[index + 1]);
855+
} else {
856+
expect(next, tokens[index + 1]);
857+
}
858+
}
859+
expect(tokens[tokens.length - 1].next, isNull);
860+
// TODO(danrubel): Implement this
861+
return null;
862+
}
863+
831864
@override
832865
CompilationUnit parseCompilationUnit2() {
833866
CompilationUnit result = super.parseCompilationUnit2();
@@ -980,7 +1013,97 @@ class RecoveryParserTest_Fasta extends FastaParserTestCase
9801013

9811014
@reflectiveTest
9821015
class SimpleParserTest_Fasta extends FastaParserTestCase
983-
with SimpleParserTestMixin {}
1016+
with SimpleParserTestMixin {
1017+
@override
1018+
@failingTest
1019+
void test_parseCommentReferences_multiLine() {
1020+
super.test_parseCommentReferences_multiLine();
1021+
}
1022+
1023+
@override
1024+
@failingTest
1025+
void test_parseCommentReferences_notClosed_noIdentifier() {
1026+
super.test_parseCommentReferences_notClosed_noIdentifier();
1027+
}
1028+
1029+
@override
1030+
@failingTest
1031+
void test_parseCommentReferences_notClosed_withIdentifier() {
1032+
super.test_parseCommentReferences_notClosed_withIdentifier();
1033+
}
1034+
1035+
@override
1036+
@failingTest
1037+
void test_parseCommentReferences_singleLine() {
1038+
super.test_parseCommentReferences_singleLine();
1039+
}
1040+
1041+
@override
1042+
@failingTest
1043+
void test_parseCommentReferences_skipCodeBlock_4spaces_block() {
1044+
super.test_parseCommentReferences_skipCodeBlock_4spaces_block();
1045+
}
1046+
1047+
@override
1048+
@failingTest
1049+
void test_parseCommentReferences_skipCodeBlock_4spaces_lines() {
1050+
super.test_parseCommentReferences_skipCodeBlock_4spaces_lines();
1051+
}
1052+
1053+
@override
1054+
@failingTest
1055+
void test_parseCommentReferences_skipCodeBlock_bracketed() {
1056+
super.test_parseCommentReferences_skipCodeBlock_bracketed();
1057+
}
1058+
1059+
@override
1060+
@failingTest
1061+
void test_parseCommentReferences_skipCodeBlock_gitHub() {
1062+
super.test_parseCommentReferences_skipCodeBlock_gitHub();
1063+
}
1064+
1065+
@override
1066+
@failingTest
1067+
void test_parseCommentReferences_skipCodeBlock_gitHub_multiLine() {
1068+
super.test_parseCommentReferences_skipCodeBlock_gitHub_multiLine();
1069+
}
1070+
1071+
@override
1072+
@failingTest
1073+
void test_parseCommentReferences_skipCodeBlock_gitHub_multiLine_lines() {
1074+
super.test_parseCommentReferences_skipCodeBlock_gitHub_multiLine_lines();
1075+
}
1076+
1077+
@override
1078+
@failingTest
1079+
void test_parseCommentReferences_skipCodeBlock_gitHub_notTerminated() {
1080+
super.test_parseCommentReferences_skipCodeBlock_gitHub_notTerminated();
1081+
}
1082+
1083+
@override
1084+
@failingTest
1085+
void test_parseCommentReferences_skipCodeBlock_spaces() {
1086+
super.test_parseCommentReferences_skipCodeBlock_spaces();
1087+
}
1088+
1089+
@override
1090+
@failingTest
1091+
void test_parseCommentReferences_skipLinkDefinition() {
1092+
super.test_parseCommentReferences_skipLinkDefinition();
1093+
}
1094+
1095+
@override
1096+
@failingTest
1097+
void test_parseCommentReferences_skipLinked() {
1098+
super.test_parseCommentReferences_skipLinked();
1099+
}
1100+
1101+
@override
1102+
@failingTest
1103+
void test_parseCommentReferences_skipReferenceLink() {
1104+
super.test_parseCommentReferences_skipReferenceLink();
1105+
}
1106+
}
9841107

9851108
/**
9861109
* Tests of the fasta parser based on [StatementParserTestMixin].

0 commit comments

Comments
 (0)