Remove clearCache() from SourceFactory and UriResolver.
We don't use them anymore, the whole context collection is recreated.
Change-Id: Ie07d330a4928c3f85663a86d1dc83d8e3e28ab95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/context/source.dart b/pkg/analyzer/lib/src/context/source.dart
index f30c15c..ff628f6 100644
--- a/pkg/analyzer/lib/src/context/source.dart
+++ b/pkg/analyzer/lib/src/context/source.dart
@@ -64,14 +64,6 @@
}
@override
- void clearCache() {
- _absoluteUriToSourceCache.clear();
- for (var resolver in resolvers) {
- resolver.clearCache();
- }
- }
-
- @override
Source? forUri(String absoluteUri) {
try {
Uri uri;
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index f134a33..69ac8ca 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -271,10 +271,6 @@
/// the package (or [null] if there is no registered package URI resolver).
Map<String, List<Folder>>? get packageMap;
- /// Clear any cached URI resolution information in the [SourceFactory] itself,
- /// and also ask each [UriResolver]s to clear its caches.
- void clearCache();
-
/// Return a source object representing the given absolute URI, or `null` if
/// the URI is not a valid URI or if it is not an absolute URI.
///
@@ -413,16 +409,7 @@
/// The abstract class `UriResolver` defines the behavior of objects that are
/// used to resolve URI's for a source factory. Subclasses of this class are
/// expected to resolve a single scheme of absolute URI.
-///
-/// NOTICE: in a future breaking change release of the analyzer, a method
-/// `void clearCache()` will be added. Clients that implement, but do not
-/// extend, this class, can prepare for the breaking change by adding an
-/// implementation of this method that clears any cached URI resolution
-/// information.
abstract class UriResolver {
- /// Clear any cached URI resolution information.
- void clearCache() {}
-
/// Resolve the given absolute [uri]. Return a [Source] representing the file
/// to which it was resolved, whether or not the resulting source exists, or
/// `null` if it could not be resolved because the URI is invalid.
diff --git a/pkg/analyzer/lib/src/workspace/bazel.dart b/pkg/analyzer/lib/src/workspace/bazel.dart
index aa3aec8..d7743a0 100644
--- a/pkg/analyzer/lib/src/workspace/bazel.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel.dart
@@ -53,12 +53,6 @@
_context = workspace.provider.pathContext;
@override
- void clearCache() {
- _sourceCache.clear();
- _workspace.clearCache();
- }
-
- @override
Source? resolveAbsolute(Uri uri) {
var source = _sourceCache[uri];
if (source == null) {
@@ -238,10 +232,6 @@
@override
UriResolver get packageUriResolver => BazelPackageUriResolver(this);
- void clearCache() {
- _directoryToPackage.clear();
- }
-
@override
SourceFactory createSourceFactory(
DartSdk? sdk,
diff --git a/pkg/analyzer/test/src/dart/analysis/base.dart b/pkg/analyzer/test/src/dart/analysis/base.dart
index 7f3d1cb..a015fec 100644
--- a/pkg/analyzer/test/src/dart/analysis/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/base.dart
@@ -159,9 +159,6 @@
Uri? Function(Source)? restoreAbsoluteFunction;
@override
- void clearCache() {}
-
- @override
noSuchMethod(Invocation invocation) {
throw StateError('Unexpected invocation of ${invocation.memberName}');
}