Commit 18362ec6 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Improve the debugDumpFoo output (#6882)

parent bf2c46e2
......@@ -80,24 +80,27 @@ final RegExp _indentPattern = new RegExp('^ *(?:[-+*] |[0-9]+[.):] )?');
enum _WordWrapParseMode { inSpace, inWord, atBreak }
/// Wraps the given string at the given width.
///
/// Wrapping occurs at space characters (U+0020). Lines that start
/// with an octothorpe ("#", U+0023) are not wrapped (so for example,
/// Dart stack traces won't be wrapped).
/// Wrapping occurs at space characters (U+0020). Lines that start with an
/// octothorpe ("#", U+0023) are not wrapped (so for example, Dart stack traces
/// won't be wrapped).
///
/// This is not suitable for use with arbitrary Unicode text. For
/// example, it doesn't implement UAX #14, can't handle ideographic
/// text, doesn't hyphenate, and so forth. It is only intended for
/// formatting error messages.
/// Subsequent lines attempt to duplicate the indentation of the first line, for
/// example if the first line starts with multiple spaces. In addition, if a
/// `wrapIndent` argument is provided, each line after the first is prefixed by
/// that string.
///
/// The default [debugPrint] implementation uses this for its line
/// wrapping.
Iterable<String> debugWordWrap(String message, int width) sync* {
/// This is not suitable for use with arbitrary Unicode text. For example, it
/// doesn't implement UAX #14, can't handle ideographic text, doesn't hyphenate,
/// and so forth. It is only intended for formatting error messages.
///
/// The default [debugPrint] implementation uses this for its line wrapping.
Iterable<String> debugWordWrap(String message, int width, { String wrapIndent: '' }) sync* {
if (message.length < width || message[0] == '#') {
yield message;
return;
}
Match prefixMatch = _indentPattern.matchAsPrefix(message);
String prefix = ' ' * prefixMatch.group(0).length;
String prefix = wrapIndent + ' ' * prefixMatch.group(0).length;
int start = 0;
int startForLengthCalculations = 0;
bool addPrefix = false;
......
......@@ -2410,7 +2410,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
List<String> description = <String>[];
debugFillDescription(description);
result += description
.expand((String description) => description.split('\n'))
.expand((String description) => debugWordWrap(description, 65, wrapIndent: ' '))
.map/*<String>*/((String line) => "$descriptionPrefix$line\n")
.join();
if (childrenDescription == '')
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:developer';
import 'dart:io' show Platform;
import 'dart:ui' as ui show Scene, SceneBuilder, window;
import 'package:vector_math/vector_math_64.dart';
......@@ -171,8 +172,14 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
@override
void debugFillDescription(List<String> description) {
// call to ${super.debugFillDescription(prefix)} is omitted because the root superclasses don't include any interesting information for this class
assert(() {
description.add('debug mode enabled - ${Platform.operatingSystem}');
return true;
});
description.add('window size: ${ui.window.physicalSize} (in physical pixels)');
description.add('device pixel ratio: ${ui.window.devicePixelRatio} (physical pixels per logical pixel)');
description.add('configuration: $configuration (in logical pixels)');
if (ui.window.semanticsEnabled)
description.add('semantics enabled');
}
}
......@@ -2578,19 +2578,7 @@ abstract class Element implements BuildContext {
}
if (node != null)
chain.add('\u22EF');
String result = '';
String line = '';
for (String link in chain) {
if (line != '')
line += ' \u2190 ';
if (link.length > 3 && line.length + link.length > 65) {
result += '$line\n';
line = ' ';
}
line += link;
}
result += line;
return result;
return chain.join(' \u2190 ');
}
/// A short, textual description of this element.
......@@ -2637,8 +2625,8 @@ abstract class Element implements BuildContext {
if (children.length > 0) {
Element last = children.removeLast();
for (Element child in children)
result += '${child.toStringDeep("$prefixOtherLines \u251C", "$prefixOtherLines \u2502")}';
result += '${last.toStringDeep("$prefixOtherLines \u2514", "$prefixOtherLines ")}';
result += '${child.toStringDeep("$prefixOtherLines\u251C", "$prefixOtherLines\u2502")}';
result += '${last.toStringDeep("$prefixOtherLines\u2514", "$prefixOtherLines ")}';
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment