convertAnalysisErrors method
List<AnalysisError>
convertAnalysisErrors(
- List<
Diagnostic> diagnostics, { - LineInfo? lineInfo,
- AnalysisOptions? options,
Converts the list of analysis diagnostics
from the 'analyzer' package to
a list of analysis errors defined by the plugin API.
The severities of the errors are altered based on options
.
Implementation
List<plugin.AnalysisError> convertAnalysisErrors(
List<analyzer.Diagnostic> diagnostics, {
// TODO(srawlins): Make `lineInfo` required and non-nullable, in a breaking
// change release.
analyzer.LineInfo? lineInfo,
// TODO(srawlins): Make `options` required and non-nullable, in a breaking
// change release.
analyzer.AnalysisOptions? options,
}) {
var serverErrors = <plugin.AnalysisError>[];
for (var diagnostic in diagnostics) {
var processor = analyzer.ErrorProcessor.getProcessor(options, diagnostic);
if (processor != null) {
var severity = processor.severity;
// Errors with null severity are filtered out.
if (severity != null) {
// Specified severities override.
serverErrors.add(
convertAnalysisError(
diagnostic,
lineInfo: lineInfo,
severity: severity,
),
);
}
} else {
serverErrors.add(convertAnalysisError(diagnostic, lineInfo: lineInfo));
}
}
return serverErrors;
}