Skip to content

Commit 5a9418b

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
analyzer: Support hideConstantImplementations directive
Directive introduced in dart-lang/dartdoc#3398 but not documented yet. Still experimental, but used by Flutter. Change-Id: I277927a54caf926b0b3d13db589486465ab9358d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328180 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 2369eca commit 5a9418b

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

pkg/analyzer/lib/dart/ast/doc_comment.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ enum DocDirectiveType {
248248
],
249249
),
250250

251+
/// A [DocDirective] indicating that constants should not have their own
252+
/// pages or implementations displayed.
253+
hideConstantImplementations('hideConstantImplementations'),
254+
251255
/// A [DocDirective] declaring a block of HTML content which is to be inserted
252256
/// after all other processing, including Markdown parsing.
253257
///

pkg/analyzer/lib/src/fasta/doc_comment_builder.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ final class DocCommentBuilder {
403403
case 'example':
404404
_pushDocDirective(parser.simpleDirective(DocDirectiveType.example));
405405
return true;
406+
case 'hideConstantImplementations':
407+
_pushDocDirective(parser
408+
.simpleDirective(DocDirectiveType.hideConstantImplementations));
409+
return true;
406410
case 'inject-html':
407411
_parseBlockDocDirectiveTag(parser, DocDirectiveType.injectHtml);
408412
return true;

pkg/analyzer/test/src/dart/parser/doc_comment_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,30 @@ Comment
11091109
''');
11101110
}
11111111

1112+
test_hideConstantImplementations() {
1113+
final parseResult = parseStringWithErrors(r'''
1114+
int x = 0;
1115+
1116+
/// Text.
1117+
/// {@hideConstantImplementations}
1118+
class A {}
1119+
''');
1120+
parseResult.assertNoErrors();
1121+
1122+
final node = parseResult.findNode.comment('hideConstantImplementations');
1123+
assertParsedNodeText(node, r'''
1124+
Comment
1125+
tokens
1126+
/// Text.
1127+
/// {@hideConstantImplementations}
1128+
docDirectives
1129+
SimpleDocDirective
1130+
tag
1131+
offset: [26, 57]
1132+
type: [DocDirectiveType.hideConstantImplementations]
1133+
''');
1134+
}
1135+
11121136
test_indentedCodeBlock_afterBlankLine() {
11131137
final parseResult = parseStringWithErrors(r'''
11141138
/// Text.

0 commit comments

Comments
 (0)