@@ -7,6 +7,7 @@ import 'package:analyzer/dart/ast/token.dart' as analyzer;
7
7
import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
8
8
import 'package:analyzer/error/error.dart' ;
9
9
import 'package:analyzer/error/listener.dart' show ErrorReporter;
10
+ import 'package:analyzer/src/dart/ast/token.dart' ;
10
11
import 'package:analyzer/src/dart/scanner/scanner.dart' ;
11
12
import 'package:analyzer/src/generated/parser.dart' as analyzer;
12
13
import 'package:analyzer/src/generated/utilities_dart.dart' ;
@@ -420,6 +421,22 @@ class FastaParserTestCase extends Object
420
421
return cascadeExpression.cascadeSections.first;
421
422
}
422
423
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
+
423
440
@override
424
441
CompilationUnit parseCompilationUnit (String content,
425
442
{List <ErrorCode > codes, List <ExpectedError > errors}) {
@@ -828,6 +845,22 @@ class ParserProxy extends analyzer.ParserAdapter {
828
845
return _run ('Import' , () => super .parseCombinators ());
829
846
}
830
847
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
+
831
864
@override
832
865
CompilationUnit parseCompilationUnit2 () {
833
866
CompilationUnit result = super .parseCompilationUnit2 ();
@@ -980,7 +1013,97 @@ class RecoveryParserTest_Fasta extends FastaParserTestCase
980
1013
981
1014
@reflectiveTest
982
1015
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
+ }
984
1107
985
1108
/**
986
1109
* Tests of the fasta parser based on [StatementParserTestMixin] .
0 commit comments