@@ -34,15 +34,15 @@ String format(String content, {Version? languageVersion}) {
34
34
/// cause of the failure, a list of [AnalysisError] 's.
35
35
ParseStringResult sortDirectives (String contents, {String ? fileName}) {
36
36
var (unit, errors) = _parse (contents, fullName: fileName);
37
- var hasParseErrors = errors.any ((error) =>
37
+ var parseErrors = errors.where ((error) =>
38
38
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 );
42
42
}
43
- var sorter = ImportOrganizer (contents, unit, errors );
43
+ var sorter = ImportOrganizer (contents, unit, parseErrors );
44
44
sorter.organize ();
45
- return ParseStringResultImpl (sorter.code, unit, errors );
45
+ return ParseStringResultImpl (sorter.code, unit, parseErrors );
46
46
}
47
47
48
48
(CompilationUnit , List <AnalysisError >) _parse (String contents,
0 commit comments