mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:39:48 +00:00
[tools] verify_docs
don't error on library annotations
Dartdoc code snippets should be able to have annotations before the `library` keyword. Bug: https://github.com/dart-lang/sdk/issues/49803#issuecomment-1287044157 Change-Id: I7ec0b6db296274a1173d10d900f7af38a1f2b552 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265321 Reviewed-by: Devon Carew <devoncarew@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
9319d07e11
commit
97eaded1ed
|
@ -18,6 +18,7 @@ import 'package:analyzer/error/error.dart';
|
||||||
import 'package:analyzer/file_system/overlay_file_system.dart';
|
import 'package:analyzer/file_system/overlay_file_system.dart';
|
||||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||||
import 'package:analyzer/source/line_info.dart';
|
import 'package:analyzer/source/line_info.dart';
|
||||||
|
import 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
|
||||||
import 'package:analyzer/src/error/codes.dart';
|
import 'package:analyzer/src/error/codes.dart';
|
||||||
import 'package:analyzer/src/util/comment.dart';
|
import 'package:analyzer/src/util/comment.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
@ -353,6 +354,10 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Don't error on annotations above library.
|
||||||
|
errors.removeWhere(
|
||||||
|
(e) => e.errorCode == ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST);
|
||||||
|
|
||||||
if (errors.isNotEmpty) {
|
if (errors.isNotEmpty) {
|
||||||
print('$filePath:${sample.lineStartOffset}: ${errors.length} errors');
|
print('$filePath:${sample.lineStartOffset}: ${errors.length} errors');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue