CQ. Remove not useful _ParsedFileStateCache.
It was used to support macros, so is not useful anymore. Change-Id: I12b98ed75125bc59473c9048a9f35554b5f33eae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435561 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
f5eaefd5b6
commit
eff3522827
@@ -574,9 +574,7 @@ class AnalysisDriver {
|
||||
addFile(file.path);
|
||||
}
|
||||
|
||||
void afterPerformWork() {
|
||||
_fsState.clearParsedFileStateCache();
|
||||
}
|
||||
void afterPerformWork() {}
|
||||
|
||||
/// Return a [Future] that completes after pending file changes are applied,
|
||||
/// so that [currentSession] can be used to compute results.
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/diagnostic/diagnostic.dart';
|
||||
import 'package:analyzer/error/listener.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/source/file_source.dart';
|
||||
@@ -656,7 +655,6 @@ class FileState {
|
||||
var rawFileState = _fsState.fileContentStrategy.get(path);
|
||||
var contentChanged = _fileContent?.contentHash != rawFileState.contentHash;
|
||||
_fileContent = rawFileState;
|
||||
_fsState._parsedFileStateCache.remove(this);
|
||||
|
||||
// Prepare the unlinked bundle key.
|
||||
var previousUnlinkedKey = _unlinkedKey;
|
||||
@@ -802,30 +800,6 @@ class FileState {
|
||||
return _fsState.getFileForUri(absoluteUri);
|
||||
}
|
||||
|
||||
/// Returns either new, or cached parsed result for this file.
|
||||
_ParsedFileState _getParsed({required OperationPerformanceImpl performance}) {
|
||||
var result = _fsState._parsedFileStateCache.get(this);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var diagnosticListener = RecordingDiagnosticListener();
|
||||
var unit = parseCode(
|
||||
code: content,
|
||||
diagnosticListener: diagnosticListener,
|
||||
performance: performance,
|
||||
);
|
||||
|
||||
result = _ParsedFileState(
|
||||
code: content,
|
||||
unit: unit,
|
||||
diagnostics: diagnosticListener.diagnostics,
|
||||
);
|
||||
_fsState._parsedFileStateCache.put(this, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Return the unlinked unit, freshly deserialized from bytes,
|
||||
/// previously deserialized from bytes, or new.
|
||||
AnalysisDriverUnlinkedUnit _getUnlinkedUnit(
|
||||
@@ -855,7 +829,7 @@ class FileState {
|
||||
return result;
|
||||
}
|
||||
|
||||
var unit = _getParsed(performance: performance).unit;
|
||||
var unit = parse(performance: performance);
|
||||
|
||||
return performance.run('compute', (performance) {
|
||||
var unlinkedUnit = performance.run('serializeAstUnlinked2', (
|
||||
@@ -1280,12 +1254,6 @@ class FileSystemState {
|
||||
/// store here the instance to attach [_newFile] operations.
|
||||
OperationPerformanceImpl? newFileOperationPerformance;
|
||||
|
||||
/// We cache results of parsing [FileState]s because they might be useful
|
||||
/// in the process of a single analysis operation. But after that, even
|
||||
/// if these results are still valid, they are often never used again. So,
|
||||
/// currently we clear the cache after each operation.
|
||||
final _ParsedFileStateCache _parsedFileStateCache = _ParsedFileStateCache();
|
||||
|
||||
FileSystemState(
|
||||
this._byteStore,
|
||||
this.resourceProvider,
|
||||
@@ -1340,11 +1308,6 @@ class FileSystemState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clears the parsed file state cache.
|
||||
void clearParsedFileStateCache() {
|
||||
_parsedFileStateCache.clear();
|
||||
}
|
||||
|
||||
/// Collected files that transitively reference a file with the [path].
|
||||
/// These files are potentially affected by the change.
|
||||
void collectAffected(String path, Set<FileState> affected) {
|
||||
@@ -2399,38 +2362,6 @@ class _LibraryNameToFiles {
|
||||
}
|
||||
}
|
||||
|
||||
class _ParsedFileState {
|
||||
final String code;
|
||||
final CompilationUnitImpl unit;
|
||||
final List<Diagnostic> diagnostics;
|
||||
|
||||
_ParsedFileState({
|
||||
required this.code,
|
||||
required this.unit,
|
||||
required this.diagnostics,
|
||||
});
|
||||
}
|
||||
|
||||
class _ParsedFileStateCache {
|
||||
final Map<FileState, _ParsedFileState> _map = Map.identity();
|
||||
|
||||
void clear() {
|
||||
_map.clear();
|
||||
}
|
||||
|
||||
_ParsedFileState? get(FileState file) {
|
||||
return _map[file];
|
||||
}
|
||||
|
||||
void put(FileState file, _ParsedFileState result) {
|
||||
_map[file] = result;
|
||||
}
|
||||
|
||||
void remove(FileState file) {
|
||||
_map.remove(file);
|
||||
}
|
||||
}
|
||||
|
||||
extension on List<DirectiveState> {
|
||||
void disposeAll() {
|
||||
for (var directive in this) {
|
||||
|
||||
@@ -304,7 +304,6 @@ class FileResolver {
|
||||
for (var filePath in result) {
|
||||
await collectReferences2(filePath, performance!);
|
||||
}
|
||||
_clearFileSystemStateParsedCache();
|
||||
}
|
||||
return references;
|
||||
});
|
||||
@@ -415,7 +414,6 @@ class FileResolver {
|
||||
|
||||
performance.run('libraryContext', (performance) {
|
||||
libraryContext!.load(targetLibrary: kind, performance: performance);
|
||||
_clearFileSystemStateParsedCache();
|
||||
});
|
||||
|
||||
return libraryContext!.elementFactory.libraryOfUri2(uri);
|
||||
@@ -515,7 +513,6 @@ class FileResolver {
|
||||
path: libraryFile.path,
|
||||
performance: performance,
|
||||
);
|
||||
_clearFileSystemStateParsedCache();
|
||||
var unit = libraryResult.units.firstWhereOrNull(
|
||||
(unitResult) => unitResult.path == path,
|
||||
);
|
||||
@@ -575,7 +572,6 @@ class FileResolver {
|
||||
performance: OperationPerformanceImpl('<root>'),
|
||||
typeSystemOperations: typeSystemOperations,
|
||||
);
|
||||
_clearFileSystemStateParsedCache();
|
||||
|
||||
var analysisResult = performance!.run('analyze', (performance) {
|
||||
return libraryAnalyzer.analyzeForCompletion(
|
||||
@@ -678,10 +674,6 @@ class FileResolver {
|
||||
});
|
||||
}
|
||||
|
||||
void _clearFileSystemStateParsedCache() {
|
||||
fsState?.clearParsedFileStateCache();
|
||||
}
|
||||
|
||||
/// Make sure that [fsState], [contextObjects], and [libraryContext] are
|
||||
/// created and configured with the given [fileAnalysisOptions].
|
||||
///
|
||||
@@ -695,10 +687,6 @@ class FileResolver {
|
||||
/// system. And there are lints that are enabled for one package, but not
|
||||
/// for another.
|
||||
void _createContext(String path, AnalysisOptionsImpl fileAnalysisOptions) {
|
||||
// Clear it here too, so that even if we miss the invocation somewhere,
|
||||
// we still eventually do it, and so limit the number of cached items.
|
||||
_clearFileSystemStateParsedCache();
|
||||
|
||||
if (contextObjects != null) {
|
||||
libraryContext!.analysisContext.analysisOptions = fileAnalysisOptions;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user