@@ -11,6 +11,7 @@ import '../hidden_ranges/hidden_ranges.dart';
11
11
import '../issues/issue.dart' ;
12
12
import '../named_sections/named_section.dart' ;
13
13
import '../named_sections/parsers/abstract.dart' ;
14
+ import '../service_comment_filter/service_comment_filter.dart' ;
14
15
import '../single_line_comments/parser/single_line_comment_parser.dart' ;
15
16
import '../single_line_comments/parser/single_line_comments.dart' ;
16
17
import '../single_line_comments/single_line_comment.dart' ;
@@ -46,17 +47,12 @@ class Code {
46
47
singleLineCommentSequences: sequences,
47
48
);
48
49
49
- final serviceComments = _filterServiceComments (
50
+ final serviceComments = ServiceCommentFilter . filter (
50
51
commentParser.comments,
51
52
namedSectionParser: namedSectionParser,
52
53
);
53
54
54
- final lines = _textToCodeLines (
55
- text: text,
56
- highlighted: highlighted,
57
- language: language,
58
- commentsByLines: commentParser.getCommentsByLines (),
59
- );
55
+ final serviceCommentsNodesSet = serviceComments.sources;
60
56
61
57
final issues = < Issue > [];
62
58
final List <FoldableBlock > foldableBlocks;
@@ -65,7 +61,7 @@ class Code {
65
61
foldableBlocks = const [];
66
62
} else {
67
63
final parser = HighlightFoldableBlockParser ();
68
- parser.parse (highlighted);
64
+ parser.parse (highlighted, serviceCommentsNodesSet );
69
65
foldableBlocks = parser.blocks;
70
66
issues.addAll (parser.invalidBlocks.map ((b) => b.issue));
71
67
}
@@ -76,6 +72,13 @@ class Code {
76
72
const [];
77
73
final sectionsMap = {for (final s in sections) s.name: s};
78
74
75
+ final lines = _textToCodeLines (
76
+ text: text,
77
+ highlighted: highlighted,
78
+ language: language,
79
+ commentsByLines: commentParser.getCommentsByLines (),
80
+ );
81
+
79
82
_applyNamedSectionsToLines (
80
83
lines: lines,
81
84
sections: sectionsMap,
@@ -125,38 +128,6 @@ class Code {
125
128
visibleText: '' ,
126
129
);
127
130
128
- static Iterable <SingleLineComment > _filterServiceComments (
129
- List <SingleLineComment > comments, {
130
- required AbstractNamedSectionParser ? namedSectionParser,
131
- }) sync * {
132
- for (final comment in comments) {
133
- if (_isServiceComment (comment, namedSectionParser: namedSectionParser)) {
134
- yield comment;
135
- }
136
- }
137
- }
138
-
139
- static bool _isServiceComment (
140
- SingleLineComment comment, {
141
- required AbstractNamedSectionParser ? namedSectionParser,
142
- }) {
143
- final words = _getCommentWords (comment.innerContent);
144
- if (words.contains (Tokens .readonly)) {
145
- return true ;
146
- }
147
-
148
- if (namedSectionParser != null ) {
149
- final namedSections = namedSectionParser.parseUnsorted (
150
- singleLineComments: [comment],
151
- );
152
- if (namedSections.isNotEmpty) {
153
- return true ;
154
- }
155
- }
156
-
157
- return false ;
158
- }
159
-
160
131
static List <CodeLine > _textToCodeLines ({
161
132
required String text,
162
133
required Result ? highlighted,
0 commit comments