Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1170)

Unified Diff: pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart

Issue 2644953002: Store a file state in the incremental resolved AST generator. (Closed)
Patch Set: Additional testing logic Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart
diff --git a/pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart b/pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart
index b647df7ea557d102268b15f20d88e631cf88526c..230fdbe192ca571e075763507002bc92b54f6412 100644
--- a/pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart
+++ b/pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart
@@ -52,6 +52,7 @@ class IncrementalResolvedAstGeneratorImpl
final ProcessedOptions _options;
final Uri _source;
bool _schedulerStarted = false;
+ final _fileState = <Uri, String>{};
IncrementalResolvedAstGeneratorImpl(this._source, this._options);
@@ -64,7 +65,10 @@ class IncrementalResolvedAstGeneratorImpl
// so we have to find all the files first to read their contents.
// TODO(paulberry): this is an unnecessary source of duplicate work and
// should be eliminated ASAP.
- var graph = await graphForProgram([_source], _options);
+ var graph =
+ await graphForProgram([_source], _options, fileReader: _fileReader);
+ // TODO(paulberry): collect no-longer-referenced files from _fileState and
+ // _fileRepository.
var libraries = <Uri, ResolvedLibrary>{};
if (!_schedulerStarted) {
_scheduler.start();
@@ -76,13 +80,9 @@ class IncrementalResolvedAstGeneratorImpl
for (var libraryCycle in graph.topologicallySortedCycles) {
for (var libraryUri in libraryCycle.libraries.keys) {
var libraryNode = libraryCycle.libraries[libraryUri];
- var libraryContents =
- await _options.fileSystem.entityForUri(libraryUri).readAsString();
- _fileRepository.store(libraryUri, libraryContents);
for (var partUri in libraryNode.parts) {
- var partContents =
- await _options.fileSystem.entityForUri(partUri).readAsString();
- _fileRepository.store(partUri, partContents);
+ // TODO(paulberry): resolve the part URI.
+ _fileReader(partUri, partUri);
}
}
for (var libraryUri in libraryCycle.libraries.keys) {
@@ -150,12 +150,21 @@ class IncrementalResolvedAstGeneratorImpl
@override
void invalidateAll() {
+ _fileState.clear();
+ _fileRepository.clearContents();
// TODO(paulberry): verify that this has an effect (requires a multi-file
// test).
if (_isInitialized) {
_driver.knownFiles.forEach(_driver.changeFile);
}
}
+
+ Future<String> _fileReader(Uri originalUri, Uri resolvedUri) async {
+ String contents = _fileState[resolvedUri] ??=
+ await _options.fileSystem.entityForUri(resolvedUri).readAsString();
+ _fileRepository.store(originalUri, contents);
+ return contents;
+ }
}
class _DartSdkProxy implements DartSdk {
« no previous file with comments | « pkg/front_end/lib/src/dependency_grapher_impl.dart ('k') | pkg/front_end/test/incremental_resolved_ast_generator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698