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

Unified Diff: pkg/analysis_server/lib/src/collections.dart

Issue 2914383002: Expose the exceptions info in the diagnostics page. (Closed)
Patch Set: Created 3 years, 7 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/analysis_server/lib/src/collections.dart
diff --git a/pkg/analysis_server/lib/src/collections.dart b/pkg/analysis_server/lib/src/collections.dart
index e89350e41d622f650f9965780142c4a6a078c616..6f4109590d23c0e1b79744ad61b865ea17a337a6 100644
--- a/pkg/analysis_server/lib/src/collections.dart
+++ b/pkg/analysis_server/lib/src/collections.dart
@@ -45,3 +45,27 @@ class Pair<E, F> {
String toString() => '($first, $last)';
}
+
+/**
+ * A container that remembers the last `n` items added to it.
+ *
+ * It will never grow larger than `capacity`. It's a LIFO queue - the last item
scheglov 2017/06/02 16:43:22 [capacity]
devoncarew 2017/06/02 16:51:02 Done.
+ * added will be the first one returned from [items].
+ */
+class RecentBuffer<T> {
+ final int capacity;
+
+ List<T> _buffer = [];
+
+ RecentBuffer(this.capacity);
+
+ void add(T item) {
+ _buffer.add(item);
+
+ if (_buffer.length > capacity) {
+ _buffer.removeAt(0);
+ }
+ }
+
+ Iterable<T> get items => _buffer.reversed;
+}

Powered by Google App Engine
This is Rietveld 408576698