Index: lib/src/pretty_print.dart |
diff --git a/lib/src/pretty_print.dart b/lib/src/pretty_print.dart |
index eb13448bfa07fe26ed6df88c94c2fc6634647c89..f8c1d15df8861c96052d493eddeecbfbe30f1aab 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,13 @@ 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; |
+ if (ch == "'") return "\\'"; |
+ else if (ch == '\n') return '\\n'; |
Siggi Cherem (dart-lang)
2015/01/14 20:30:09
we should be able to remove all the `else`s here
kevmoo
2015/01/14 22:28:45
Yup. Actually used a case statement here. Seems a
|
+ else if (ch == '\r') return '\\r'; |
+ else if (ch == '\t') return '\\t'; |
+ else return ch; |
} |
- |