Skip to content

Commit 97eaded

Browse files
dcharkesCommit Queue
authored and
Commit Queue
committed
[tools] verify_docs don't error on library annotations
Dartdoc code snippets should be able to have annotations before the `library` keyword. Bug: #49803 (comment) Change-Id: I7ec0b6db296274a1173d10d900f7af38a1f2b552 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265321 Reviewed-by: Devon Carew <[email protected]> Auto-Submit: Daco Harkes <[email protected]> Commit-Queue: Daco Harkes <[email protected]> Commit-Queue: Devon Carew <[email protected]>
1 parent 9319d07 commit 97eaded

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/verify_docs/bin/verify_docs.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:analyzer/error/error.dart';
1818
import 'package:analyzer/file_system/overlay_file_system.dart';
1919
import 'package:analyzer/file_system/physical_file_system.dart';
2020
import 'package:analyzer/source/line_info.dart';
21+
import 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
2122
import 'package:analyzer/src/error/codes.dart';
2223
import 'package:analyzer/src/util/comment.dart';
2324
import 'package:path/path.dart' as path;
@@ -353,6 +354,10 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
353354
return false;
354355
});
355356

357+
// Don't error on annotations above library.
358+
errors.removeWhere(
359+
(e) => e.errorCode == ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST);
360+
356361
if (errors.isNotEmpty) {
357362
print('$filePath:${sample.lineStartOffset}: ${errors.length} errors');
358363

0 commit comments

Comments
 (0)