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

Unified Diff: tool/input_sdk/private/debugger.dart

Issue 2137063003: Custom formatter popup booleans (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: return type fix Created 4 years, 5 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 | « lib/runtime/dart_sdk.js ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/debugger.dart
diff --git a/tool/input_sdk/private/debugger.dart b/tool/input_sdk/private/debugger.dart
index 4c29b9e1bd8bd7ec86c03646c9243abfe96dd8e4..ed6450550e965282b8e7d18041a041ba0c8738ae 100644
--- a/tool/input_sdk/private/debugger.dart
+++ b/tool/input_sdk/private/debugger.dart
@@ -126,11 +126,48 @@ class MapEntry {
}
class IterableSpan {
- IterableSpan({this.start, this.end, this.iterable});
+ IterableSpan(this.start, this.end, this.iterable);
final int start;
final int end;
final Iterable iterable;
+ int get length => end - start;
+
+ /// Using length - .5, a list of length 10000 results in a
+ /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100,
+ /// 100-length subsets. A list of length 10001 results in a
+ /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1
+ /// 10000-length subset and 1 1-length subset.
+ int get maxPowerOfSubsetSize =>
+ (log(length - .5) / log(_maxSpanLength)).truncate();
+ int get subsetSize => pow(_maxSpanLength, maxPowerOfSubsetSize);
+
+ Map<int, dynamic> asMap() =>
+ iterable.skip(start).take(length).toList().asMap();
+
+ List<NameValuePair> children() {
+ var ret = <NameValuePair>[];
+ if (length <= _maxSpanLength) {
+ asMap().forEach((i, element) {
+ ret.add(
+ new NameValuePair(name: (i + start).toString(), value: element));
+ });
+ } else {
+ for (var i = start; i < end; i += subsetSize) {
+ var subSpan = new IterableSpan(i, min(end, subsetSize + i), iterable);
+ if (subSpan.length == 1) {
+ ret.add(new NameValuePair(
+ name: i.toString(), value: iterable.elementAt(i)));
+ } else {
+ ret.add(new NameValuePair(
+ name: '[${i}...${subSpan.end - 1}]',
+ value: subSpan,
+ hideName: true));
+ }
+ }
+ }
+ return ret;
+ }
}
class ClassMetadata {
@@ -218,6 +255,8 @@ class JsonMLFormatter {
// DartFormatter.
DartFormatter _simpleFormatter;
+ bool customFormattersOn = false;
+
JsonMLFormatter(this._simpleFormatter);
void setMaxSpanLengthForTestingOnly(int spanLength) {
@@ -225,6 +264,7 @@ class JsonMLFormatter {
}
header(object, config) {
+ customFormattersOn = true;
if (config == JsonMLConfig.skipDart || isNativeJavaScriptObject(object)) {
return null;
}
@@ -517,8 +557,7 @@ class IterableFormatter extends ObjectFormatter {
// TODO(jacobr): handle large Iterables better.
// TODO(jacobr): consider only using numeric indices
var ret = new LinkedHashSet<NameValuePair>();
- ret.addAll(childrenHelper(
- new IterableSpan(start: 0, end: object.length, iterable: object)));
+ ret.addAll((new IterableSpan(0, object.length, object)).children());
// TODO(jacobr): provide a link to show regular class properties here.
// required for subclasses of iterable, etc.
addMetadataChildren(object, ret);
@@ -625,50 +664,12 @@ class IterableSpanFormatter implements Formatter {
accept(object) => object is IterableSpan;
String preview(object) {
- IterableSpan entry = object;
return '[${object.start}...${object.end-1}]';
}
bool hasChildren(object) => true;
- List<NameValuePair> children(object) => childrenHelper(object);
-}
-
-List<NameValuePair> childrenHelper(IterableSpan span) {
- var length = span.end - span.start;
- var ret = new List<NameValuePair>();
- if (length <= _maxSpanLength) {
- for (var i = span.start; i < span.end; i++) {
- /// TODO(bmilligan): Stop using elementAt if it becomes a performance
- /// bottleneck in the future.
- ret.add(new NameValuePair(
- name: i.toString(), value: span.iterable.elementAt(i)));
- }
- } else {
- /// Using length - .5, a list of length 10000 results in a
- /// maxPowerOfSubsetSize of 1, so the list will be broken up into 100,
- /// 100-length subsets. A list of length 10001 results in a
- /// maxPowerOfSubsetSize of 2, so the list will be broken up into 1
- /// 10000-length subset and 1 1-length subset.
- var maxPowerOfSubsetSize =
- (log(length - .5) / log(_maxSpanLength)).truncate();
- var subsetSize = pow(_maxSpanLength, maxPowerOfSubsetSize);
- for (var i = span.start; i < span.end; i += subsetSize) {
- var endIndex = min(span.end, subsetSize + i);
- if (endIndex - i == 1)
- ret.add(new NameValuePair(
- name: i.toString(), value: span.iterable.elementAt(i)));
- else {
- var entryWrapper =
- new IterableSpan(start: i, end: endIndex, iterable: span.iterable);
- ret.add(new NameValuePair(
- name: '[${i}...${endIndex - 1}]',
- value: entryWrapper,
- hideName: true));
- }
- }
- }
- return ret;
+ List<NameValuePair> children(object) => object.children();
}
/// This entry point is automatically invoked by the code generated by
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698