analyze method
Future<List<EndpointDefinition> >
analyze({
- required CodeAnalysisCollector collector,
- Set<
String> ? changedFiles,
Analyze all files in the AnalysisContextCollection.
Use changedFiles to mark files, that need reloading.
Implementation
Future<List<EndpointDefinition>> analyze({
required CodeAnalysisCollector collector,
Set<String>? changedFiles,
}) async {
await _refreshContextForFiles(changedFiles);
var endpointDefs = <EndpointDefinition>[];
await for (var (library, filePath, rootPath) in _libraries) {
var maybeDartErrors = await _getErrorsForFile(library.session, filePath);
if (maybeDartErrors.isNotEmpty) {
collector.addError(
SourceSpanSeverityException(
'Endpoint analysis skipped due to invalid Dart syntax. Please '
'review and correct the syntax errors.'
'\nFile: $filePath',
null,
severity: SourceSpanSeverity.error,
),
);
continue;
}
var validationErrors = _validateLibrary(library, filePath);
collector.addErrors(validationErrors.values.expand((e) => e).toList());
endpointDefs.addAll(
_parseLibrary(
library,
collector,
filePath,
rootPath,
validationErrors,
),
);
}
return endpointDefs;
}