toDartAnalysisErrors method
Iterable<DartAnalysisError>
toDartAnalysisErrors({
- required ResolvedUnitResult result,
- required CandiesLintsIgnoreInfo ignoreInfo,
- required CandiesLintsConfig? config,
Implementation
Iterable<DartAnalysisError> toDartAnalysisErrors({
required ResolvedUnitResult result,
required CandiesLintsIgnoreInfo ignoreInfo,
required CandiesLintsConfig? config,
}) sync* {
final Map<SyntacticEntity, AstNode> copy = <SyntacticEntity, AstNode>{};
copy.addAll(_astNodes);
if (copy.isNotEmpty) {
CandiesLintsLogger().log(
'find ${copy.length} lint($code) at ${result.path}',
root: result.root,
);
}
_astNodes.clear();
final List<DartAnalysisError> errors = <DartAnalysisError>[];
_cacheErrorsForFixes[result.path] = errors;
for (final SyntacticEntity syntacticEntity in copy.keys) {
final Location location = astNodeToLocation(
result,
syntacticEntity,
);
if (!ignoreInfo.ignoredAt(code, location.startLine)) {
final DartAnalysisError error = toDartAnalysisError(
result: result,
location: location,
astNode: copy[syntacticEntity]!,
ignoreInfo: ignoreInfo,
config: config,
);
errors.add(error);
yield error;
} else {
CandiesLintsLogger().log(
'ignore code: $code at ${result.lineNumber(syntacticEntity.offset)} line in ${result.path}',
root: result.root,
);
}
}
}