Skip to content

Commit f06e372

Browse files
davidmorganCommit Queue
authored and
Commit Queue
committed
[analyzer] Return only relevant errors in sortDirectives.
Trying 3.7.0 I hit a case where this would succeed but return an error "Doc directive 'code' is unknown." Per the doc comment it looks like the error should not be returned. [email protected] Change-Id: Id2d65adcf4ce59caa16040fcce9457b2c7f244a2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391740 Auto-Submit: Morgan :) <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent de058e0 commit f06e372

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/analysis_server/lib/src/g3/utilities.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ String format(String content, {Version? languageVersion}) {
3434
/// cause of the failure, a list of [AnalysisError]'s.
3535
ParseStringResult sortDirectives(String contents, {String? fileName}) {
3636
var (unit, errors) = _parse(contents, fullName: fileName);
37-
var hasParseErrors = errors.any((error) =>
37+
var parseErrors = errors.where((error) =>
3838
error.errorCode is ScannerErrorCode ||
39-
error.errorCode is ParserErrorCode);
40-
if (hasParseErrors) {
41-
return ParseStringResultImpl(contents, unit, errors);
39+
error.errorCode is ParserErrorCode).toList();
40+
if (parseErrors.isNotEmpty) {
41+
return ParseStringResultImpl(contents, unit, parseErrors);
4242
}
43-
var sorter = ImportOrganizer(contents, unit, errors);
43+
var sorter = ImportOrganizer(contents, unit, parseErrors);
4444
sorter.organize();
45-
return ParseStringResultImpl(sorter.code, unit, errors);
45+
return ParseStringResultImpl(sorter.code, unit, parseErrors);
4646
}
4747

4848
(CompilationUnit, List<AnalysisError>) _parse(String contents,

0 commit comments

Comments
 (0)