@@ -13,7 +13,6 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
13
13
import 'package:analyzer/dart/analysis/features.dart' ;
14
14
import 'package:analyzer/dart/ast/token.dart' ;
15
15
import 'package:analyzer/dart/element/element.dart' ;
16
- import 'package:analyzer/diagnostic/diagnostic.dart' ;
17
16
import 'package:analyzer/error/listener.dart' ;
18
17
import 'package:analyzer/file_system/file_system.dart' ;
19
18
import 'package:analyzer/source/file_source.dart' ;
@@ -656,7 +655,6 @@ class FileState {
656
655
var rawFileState = _fsState.fileContentStrategy.get (path);
657
656
var contentChanged = _fileContent? .contentHash != rawFileState.contentHash;
658
657
_fileContent = rawFileState;
659
- _fsState._parsedFileStateCache.remove (this );
660
658
661
659
// Prepare the unlinked bundle key.
662
660
var previousUnlinkedKey = _unlinkedKey;
@@ -802,30 +800,6 @@ class FileState {
802
800
return _fsState.getFileForUri (absoluteUri);
803
801
}
804
802
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
-
829
803
/// Return the unlinked unit, freshly deserialized from bytes,
830
804
/// previously deserialized from bytes, or new.
831
805
AnalysisDriverUnlinkedUnit _getUnlinkedUnit (
@@ -855,7 +829,7 @@ class FileState {
855
829
return result;
856
830
}
857
831
858
- var unit = _getParsed (performance: performance).unit ;
832
+ var unit = parse (performance: performance);
859
833
860
834
return performance.run ('compute' , (performance) {
861
835
var unlinkedUnit = performance.run ('serializeAstUnlinked2' , (
@@ -1280,12 +1254,6 @@ class FileSystemState {
1280
1254
/// store here the instance to attach [_newFile] operations.
1281
1255
OperationPerformanceImpl ? newFileOperationPerformance;
1282
1256
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
-
1289
1257
FileSystemState (
1290
1258
this ._byteStore,
1291
1259
this .resourceProvider,
@@ -1340,11 +1308,6 @@ class FileSystemState {
1340
1308
}
1341
1309
}
1342
1310
1343
- /// Clears the parsed file state cache.
1344
- void clearParsedFileStateCache () {
1345
- _parsedFileStateCache.clear ();
1346
- }
1347
-
1348
1311
/// Collected files that transitively reference a file with the [path] .
1349
1312
/// These files are potentially affected by the change.
1350
1313
void collectAffected (String path, Set <FileState > affected) {
@@ -2399,38 +2362,6 @@ class _LibraryNameToFiles {
2399
2362
}
2400
2363
}
2401
2364
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
-
2434
2365
extension on List <DirectiveState > {
2435
2366
void disposeAll () {
2436
2367
for (var directive in this ) {
0 commit comments