Skip to content

Commit 30d7a0c

Browse files
DanTupCommit Bot
authored and
Commit Bot
committed
[analysis_server] Don't re-analyze on watch events for files that have overlays
Existing tests like `test_fileSystem_changeFile_hasOverlay_removeOverlay` verify that removing the overlay correctly re-reads content from disk. Change-Id: I05660acfe81e35fd4b247d8c7b901903bb67f728 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253780 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent f2f4b6d commit 30d7a0c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/analysis_server/lib/src/context_manager.dart

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:analyzer/dart/analysis/analysis_context.dart';
1111
import 'package:analyzer/dart/analysis/features.dart';
1212
import 'package:analyzer/error/listener.dart';
1313
import 'package:analyzer/file_system/file_system.dart';
14+
import 'package:analyzer/file_system/overlay_file_system.dart';
1415
import 'package:analyzer/instrumentation/instrumentation.dart';
1516
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
1617
import 'package:analyzer/src/dart/analysis/byte_store.dart';
@@ -138,8 +139,9 @@ abstract class ContextManagerCallbacks {
138139
/// Class that maintains a mapping from included/excluded paths to a set of
139140
/// folders that should correspond to analysis contexts.
140141
class ContextManagerImpl implements ContextManager {
141-
/// The [ResourceProvider] using which paths are converted into [Resource]s.
142-
final ResourceProvider resourceProvider;
142+
/// The [OverlayResourceProvider] used to check for the existence of overlays
143+
/// and to convert paths into [Resource].
144+
final OverlayResourceProvider resourceProvider;
143145

144146
/// The manager used to access the SDK that should be associated with a
145147
/// particular context.
@@ -738,7 +740,12 @@ class ContextManagerImpl implements ContextManager {
738740
}
739741

740742
var collection = _collection;
741-
if (collection != null && file_paths.isDart(pathContext, path)) {
743+
if (collection != null &&
744+
file_paths.isDart(pathContext, path) &&
745+
// If this resource has an overlay, then the change on disk will never
746+
// affect analysis results so can be skipped. Removing the overlay will
747+
// re-read the contents from disk.
748+
!resourceProvider.hasOverlay(path)) {
742749
for (var analysisContext in collection.contexts) {
743750
switch (type) {
744751
case ChangeType.ADD:

0 commit comments

Comments
 (0)