File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
5
import 'package:analyzer/dart/ast/ast.dart' ;
6
+ import 'package:analyzer/dart/ast/doc_comment.dart' ;
6
7
import 'package:analyzer/dart/ast/visitor.dart' ;
7
8
8
9
import '../analyzer.dart' ;
@@ -69,13 +70,14 @@ class _Visitor extends SimpleAstVisitor<void> {
69
70
@override
70
71
void visitComment (Comment node) {
71
72
for (var codeBlock in node.codeBlocks) {
72
- if (codeBlock.infoString == null ) {
73
- var openingCodeBlockFence = codeBlock.lines.first;
74
- rule.reportLintForOffset (
75
- openingCodeBlockFence.offset,
76
- openingCodeBlockFence.length,
77
- );
78
- }
73
+ if (codeBlock.infoString != null ) continue ;
74
+ if (codeBlock.type != CodeBlockType .fenced) continue ;
75
+
76
+ var openingCodeBlockFence = codeBlock.lines.first;
77
+ rule.reportLintForOffset (
78
+ openingCodeBlockFence.offset,
79
+ openingCodeBlockFence.length,
80
+ );
79
81
}
80
82
}
81
83
}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class MissingCodeBlockLanguageInDocCommentTest extends LintRuleTest {
22
22
/// ```dart
23
23
/// test
24
24
/// ```
25
+ class A {}
25
26
''' );
26
27
}
27
28
@@ -43,6 +44,17 @@ class A {}
43
44
''' );
44
45
}
45
46
47
+ test_indentedCodeBlock () async {
48
+ await assertNoDiagnostics (r'''
49
+ /// Example:
50
+ ///
51
+ /// var printer = Printer();
52
+ /// printer.printToStdout();
53
+ ///
54
+ class A {}
55
+ ''' );
56
+ }
57
+
46
58
test_missingLanguage () async {
47
59
await assertDiagnostics (r'''
48
60
/// ```
You can’t perform that action at this time.
0 commit comments