@@ -13,7 +13,6 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
1313import 'package:analyzer/dart/analysis/features.dart' ;
1414import 'package:analyzer/dart/ast/token.dart' ;
1515import 'package:analyzer/dart/element/element.dart' ;
16- import 'package:analyzer/diagnostic/diagnostic.dart' ;
1716import 'package:analyzer/error/listener.dart' ;
1817import 'package:analyzer/file_system/file_system.dart' ;
1918import 'package:analyzer/source/file_source.dart' ;
@@ -656,7 +655,6 @@ class FileState {
656655 var rawFileState = _fsState.fileContentStrategy.get (path);
657656 var contentChanged = _fileContent? .contentHash != rawFileState.contentHash;
658657 _fileContent = rawFileState;
659- _fsState._parsedFileStateCache.remove (this );
660658
661659 // Prepare the unlinked bundle key.
662660 var previousUnlinkedKey = _unlinkedKey;
@@ -802,30 +800,6 @@ class FileState {
802800 return _fsState.getFileForUri (absoluteUri);
803801 }
804802
805- /// Returns either new, or cached parsed result for this file.
806- _ParsedFileState _getParsed ({required OperationPerformanceImpl performance}) {
807- var result = _fsState._parsedFileStateCache.get (this );
808- if (result != null ) {
809- return result;
810- }
811-
812- var diagnosticListener = RecordingDiagnosticListener ();
813- var unit = parseCode (
814- code: content,
815- diagnosticListener: diagnosticListener,
816- performance: performance,
817- );
818-
819- result = _ParsedFileState (
820- code: content,
821- unit: unit,
822- diagnostics: diagnosticListener.diagnostics,
823- );
824- _fsState._parsedFileStateCache.put (this , result);
825-
826- return result;
827- }
828-
829803 /// Return the unlinked unit, freshly deserialized from bytes,
830804 /// previously deserialized from bytes, or new.
831805 AnalysisDriverUnlinkedUnit _getUnlinkedUnit (
@@ -855,7 +829,7 @@ class FileState {
855829 return result;
856830 }
857831
858- var unit = _getParsed (performance: performance).unit ;
832+ var unit = parse (performance: performance);
859833
860834 return performance.run ('compute' , (performance) {
861835 var unlinkedUnit = performance.run ('serializeAstUnlinked2' , (
@@ -1280,12 +1254,6 @@ class FileSystemState {
12801254 /// store here the instance to attach [_newFile] operations.
12811255 OperationPerformanceImpl ? newFileOperationPerformance;
12821256
1283- /// We cache results of parsing [FileState] s because they might be useful
1284- /// in the process of a single analysis operation. But after that, even
1285- /// if these results are still valid, they are often never used again. So,
1286- /// currently we clear the cache after each operation.
1287- final _ParsedFileStateCache _parsedFileStateCache = _ParsedFileStateCache ();
1288-
12891257 FileSystemState (
12901258 this ._byteStore,
12911259 this .resourceProvider,
@@ -1340,11 +1308,6 @@ class FileSystemState {
13401308 }
13411309 }
13421310
1343- /// Clears the parsed file state cache.
1344- void clearParsedFileStateCache () {
1345- _parsedFileStateCache.clear ();
1346- }
1347-
13481311 /// Collected files that transitively reference a file with the [path] .
13491312 /// These files are potentially affected by the change.
13501313 void collectAffected (String path, Set <FileState > affected) {
@@ -2399,38 +2362,6 @@ class _LibraryNameToFiles {
23992362 }
24002363}
24012364
2402- class _ParsedFileState {
2403- final String code;
2404- final CompilationUnitImpl unit;
2405- final List <Diagnostic > diagnostics;
2406-
2407- _ParsedFileState ({
2408- required this .code,
2409- required this .unit,
2410- required this .diagnostics,
2411- });
2412- }
2413-
2414- class _ParsedFileStateCache {
2415- final Map <FileState , _ParsedFileState > _map = Map .identity ();
2416-
2417- void clear () {
2418- _map.clear ();
2419- }
2420-
2421- _ParsedFileState ? get (FileState file) {
2422- return _map[file];
2423- }
2424-
2425- void put (FileState file, _ParsedFileState result) {
2426- _map[file] = result;
2427- }
2428-
2429- void remove (FileState file) {
2430- _map.remove (file);
2431- }
2432- }
2433-
24342365extension on List <DirectiveState > {
24352366 void disposeAll () {
24362367 for (var directive in this ) {
0 commit comments