| Index: lib/src/pretty_print.dart
|
| diff --git a/lib/src/pretty_print.dart b/lib/src/pretty_print.dart
|
| index eb13448bfa07fe26ed6df88c94c2fc6634647c89..df93dbb013fe3af7a815c19e17529e280a4343ce 100644
|
| --- a/lib/src/pretty_print.dart
|
| +++ b/lib/src/pretty_print.dart
|
| @@ -80,8 +80,9 @@ String prettyPrint(object, {int maxLineLength, int maxItems}) {
|
| } else if (object is String) {
|
| // Escape strings and print each line on its own line.
|
| var lines = object.split("\n");
|
| - return "'" + lines.map(_escapeString)
|
| - .join("\\n'\n${_indent(indent + 2)}'") + "'";
|
| + return "'" +
|
| + lines.map(_escapeString).join("\\n'\n${_indent(indent + 2)}'") +
|
| + "'";
|
| } else {
|
| var value = object.toString().replaceAll("\n", _indent(indent) + "\n");
|
| var defaultToString = value.startsWith("Instance of ");
|
| @@ -93,8 +94,11 @@ String prettyPrint(object, {int maxLineLength, int maxItems}) {
|
| // Print the type of objects with custom [toString] methods. Primitive
|
| // objects and objects that don't implement a custom [toString] don't need
|
| // to have their types printed.
|
| - if (object is num || object is bool || object is Function ||
|
| - object == null || defaultToString) {
|
| + if (object is num ||
|
| + object is bool ||
|
| + object is Function ||
|
| + object == null ||
|
| + defaultToString) {
|
| return value;
|
| } else {
|
| return "${_typeName(object)}:$value";
|
| @@ -129,19 +133,20 @@ String _typeName(x) {
|
| /// This doesn't add quotes to the string, but it does escape single quote
|
| /// characters so that single quotes can be applied externally.
|
| String _escapeString(String source) =>
|
| - source.split("").map(_escapeChar).join("");
|
| + source.split("").map(_escapeChar).join("");
|
|
|
| /// Return the escaped form of a character [ch].
|
| String _escapeChar(String ch) {
|
| - if (ch == "'")
|
| - return "\\'";
|
| - else if (ch == '\n')
|
| - return '\\n';
|
| - else if (ch == '\r')
|
| - return '\\r';
|
| - else if (ch == '\t')
|
| - return '\\t';
|
| - else
|
| - return ch;
|
| + switch (ch) {
|
| + case "'":
|
| + return "\\'";
|
| + case '\n':
|
| + return '\\n';
|
| + case '\r':
|
| + return '\\r';
|
| + case '\t':
|
| + return '\\t';
|
| + default:
|
| + return ch;
|
| + }
|
| }
|
| -
|
|
|