@@ -223,6 +223,10 @@ class AnalysisDriver implements AnalysisDriverGeneric {
223
223
/// Cached results for [_priorityFiles] .
224
224
final Map <String , ResolvedUnitResult > _priorityResults = {};
225
225
226
+ /// Cached results of [getResolvedLibrary] .
227
+ final Map <LibraryFileKind , ResolvedLibraryResultImpl > _resolvedLibraryCache =
228
+ {};
229
+
226
230
/// The controller for the [exceptions] stream.
227
231
final StreamController <ExceptionResult > _exceptionController =
228
232
StreamController <ExceptionResult >();
@@ -484,6 +488,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
484
488
}
485
489
if (file_paths.isDart (resourceProvider.pathContext, path)) {
486
490
_priorityResults.clear ();
491
+ _resolvedLibraryCache.clear ();
487
492
_pendingFileChanges.add (
488
493
_FileChange (path, _FileChangeKind .add),
489
494
);
@@ -575,6 +580,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
575
580
}
576
581
if (file_paths.isDart (resourceProvider.pathContext, path)) {
577
582
_priorityResults.clear ();
583
+ _resolvedLibraryCache.clear ();
578
584
_pendingFileChanges.add (
579
585
_FileChange (path, _FileChangeKind .change),
580
586
);
@@ -1219,6 +1225,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
1219
1225
if (file_paths.isDart (resourceProvider.pathContext, path)) {
1220
1226
_lastProducedSignatures.remove (path);
1221
1227
_priorityResults.clear ();
1228
+ _resolvedLibraryCache.clear ();
1222
1229
_pendingFileChanges.add (
1223
1230
_FileChange (path, _FileChangeKind .remove),
1224
1231
);
@@ -1438,6 +1445,11 @@ class AnalysisDriver implements AnalysisDriverGeneric {
1438
1445
Future <ResolvedLibraryResultImpl > _computeResolvedLibrary (
1439
1446
LibraryFileKind library,
1440
1447
) async {
1448
+ final cached = _resolvedLibraryCache[library];
1449
+ if (cached != null ) {
1450
+ return cached;
1451
+ }
1452
+
1441
1453
final path = library.file.path;
1442
1454
return _logger.runAsync ('Compute resolved library $path ' , () async {
1443
1455
testView? .numOfAnalyzedLibraries++ ;
@@ -1466,11 +1478,17 @@ class AnalysisDriver implements AnalysisDriverGeneric {
1466
1478
);
1467
1479
}
1468
1480
1469
- return ResolvedLibraryResultImpl (
1481
+ final result = ResolvedLibraryResultImpl (
1470
1482
session: currentSession,
1471
1483
element: resolvedUnits.first.libraryElement,
1472
1484
units: resolvedUnits,
1473
1485
);
1486
+
1487
+ if (_isLibraryWithPriorityFile (library)) {
1488
+ _resolvedLibraryCache[library] = result;
1489
+ }
1490
+
1491
+ return result;
1474
1492
});
1475
1493
}
1476
1494
0 commit comments