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

Unified Diff: pkg/analyzer/lib/file_system/memory_file_system.dart

Issue 941883002: cache pub list results (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments and discussions Created 5 years, 10 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 | « pkg/analysis_server/test/test_all.dart ('k') | pkg/analyzer/lib/source/pub_package_map_provider.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/file_system/memory_file_system.dart
diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart
index b038f45eb92ab1863a5b45e62e64dd41ea49d581..4de46a34c4636a231438b8d95a174b45ce4bd203 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -47,6 +47,30 @@ class MemoryResourceProvider implements ResourceProvider {
@override
Context get pathContext => posix;
+ /**
+ * Simulate revoked file access
scheglov 2015/02/22 19:31:31 This comment describes the method from the perspec
danrubel 2015/02/24 02:29:45 Good point. I reworked this into a deleteFolder me
+ * and return an object that can be passed to [restore].
+ */
+ clear() {
scheglov 2015/02/22 19:31:31 Could we have some type here and in "restore"? Eve
danrubel 2015/02/24 02:29:45 That makes sense. Instead it was decided that a re
+ var restorePoint = new _MemoryRestorePoint(this);
+ _pathToResource.clear();
+ _pathToContent.clear();
+ _pathToTimestamp.clear();
+ // TODO(danrubel) notify watchers
+ return restorePoint;
+ }
+
+ /**
+ * Simulate restored file access based upon some earlier call to [clear].
+ */
+ void restore(var restorePoint) {
+ _pathToResource.clear();
+ _pathToContent.clear();
+ _pathToTimestamp.clear();
+ (restorePoint as _MemoryRestorePoint).restore(this);
+ // TODO(danrubel) notify watchers
+ }
+
void deleteFile(String path) {
_checkFileAtPath(path);
_pathToResource.remove(path);
@@ -149,6 +173,30 @@ class MemoryResourceProvider implements ResourceProvider {
/**
+ * A restore point captures the [MemoryResourceProvider] state
+ * so that it can be restored at later point.
+ */
+class _MemoryRestorePoint {
+ final Map<String, _MemoryResource> _pathToResource =
+ new HashMap<String, _MemoryResource>();
+ final Map<String, String> _pathToContent = new HashMap<String, String>();
+ final Map<String, int> _pathToTimestamp = new HashMap<String, int>();
+
+ _MemoryRestorePoint(MemoryResourceProvider provider) {
+ _pathToResource.addAll(provider._pathToResource);
+ _pathToContent.addAll(provider._pathToContent);
+ _pathToTimestamp.addAll(provider._pathToTimestamp);
+ }
+
+ void restore(MemoryResourceProvider provider) {
+ provider._pathToResource.addAll(_pathToResource);
+ provider._pathToContent.addAll(_pathToContent);
+ provider._pathToTimestamp.addAll(_pathToTimestamp);
+ }
+}
+
+
+/**
* An in-memory implementation of [File] which acts like a symbolic link to a
* non-existent file.
*/
« no previous file with comments | « pkg/analysis_server/test/test_all.dart ('k') | pkg/analyzer/lib/source/pub_package_map_provider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698