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

Unified Diff: pkg/front_end/lib/src/base/file_repository.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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/dependency_grapher_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/base/file_repository.dart
diff --git a/pkg/front_end/lib/src/base/file_repository.dart b/pkg/front_end/lib/src/base/file_repository.dart
index 5c55d86171c6c80e736b98ee63c24db8e42aa173..48223e89030dfdb58a6a5cebbc83552292a16bd9 100644
--- a/pkg/front_end/lib/src/base/file_repository.dart
+++ b/pkg/front_end/lib/src/base/file_repository.dart
@@ -21,11 +21,36 @@ class FileRepository {
/// The file contents associated with the URIs in [_uris].
final _contents = <String>[];
+ /// Clear any contents stored in the file repository. The association between
+ /// URI and arbitrary path is preserved.
+ ///
+ /// Subsequent calls to [contentsForPath] will have undefined results until
+ /// new contents are stored using [store].
+ void clearContents() {
+ for (var i = 0; i < _contents.length; i++) {
+ _contents[i] = null;
+ }
+ }
+
/// Return the contents of the file whose arbitary path is [path].
///
/// The path must have been returned by a previous call to [store] or
/// [pathForUri].
- String contentsForPath(String path) => _contents[_indexForPath(path)];
+ String contentsForPath(String path) {
+ var contents = _contents[_indexForPath(path)];
+ assert(contents != null);
+ return contents;
+ }
+
+ /// For testing purposes, return the contents of all files stored in the file
+ /// repository, as a map from path to contents string.
+ Map<String, String> getContentsForTesting() {
+ var result = <String, String>{};
+ for (var i = 0; i < _contents.length; i++) {
+ if (_contents[i] != null) result[_pathForIndex(i)] = _contents[i];
+ }
+ return result;
+ }
/// Return the arbitrary path associated with [uri].
///
« no previous file with comments | « no previous file | pkg/front_end/lib/src/dependency_grapher_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698