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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart

Issue 2442993002: API for the new AnalysisDriver. (Closed)
Patch Set: Unsaved changes. Created 4 years, 2 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/analyzer/lib/src/dart/analysis/file_byte_store.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2821268b7b303ac111567bacf87dd4ab09200415
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/dart/analysis/byte_store.dart';
+
+/**
+ * [ByteStore] that stores values as [File]s.
Paul Berry 2016/10/23 10:39:19 Should this class implement some sort of LRU polic
scheglov 2016/10/23 20:54:34 Yes, we should. I'm adding TODO.
+ */
+class FileByteStore implements ByteStore {
+ final Folder folder;
+
+ FileByteStore(this.folder);
+
+ @override
+ List<int> get(String key) {
+ try {
+ File file = folder.getChildAssumingFile(key);
+ return file.readAsBytesSync();
+ } catch (_) {
+ return null;
+ }
+ }
+
+ @override
+ void put(String key, List<int> bytes) {
+ try {
+ File file = folder.getChildAssumingFile(key);
+ file.writeAsBytesSync(bytes);
+ } catch (_) {}
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698