refreshDependencies method
Future<void>
refreshDependencies(
)
Implementation
Future<void> refreshDependencies() async {
final packageConfig = _packageConfig;
if (packageConfig == null) {
return;
}
final dependencies = await _getDependencyFiles(
packageConfig,
lastModified: _retrievedDependenciesAt,
pathDependenciesOnly: true,
);
_retrievedDependenciesAt = DateTime.now();
final pendingChanges = <Future<void>>[];
AnalysisContext? context;
for (final path in dependencies) {
final file = fs.file(path);
final bytes = switch (await file.exists()) {
true => await file.readAsBytes(),
false => null,
};
if (bytes == null) {
_memoryProvider.deleteFile(path);
} else {
_memoryProvider.newFileWithBytes(path, bytes);
}
try {
context = analysisCollection.contextFor(path)..changeFile(path);
pendingChanges.add(context.applyPendingFileChanges());
} catch (e) {
continue;
}
}
await Future.wait(pendingChanges);
}