Skip to content
Snippets Groups Projects
Commit 764f094b authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Enhancing the PrettyPrinter.scala

parent bc39cd20
Branches
Tags
No related merge requests found
...@@ -183,7 +183,7 @@ class PrettyPrinter(opts: PrinterOptions, ...@@ -183,7 +183,7 @@ class PrettyPrinter(opts: PrinterOptions,
case BooleanLiteral(v) => p"$v" case BooleanLiteral(v) => p"$v"
case UnitLiteral() => p"()" case UnitLiteral() => p"()"
case StringLiteral(v) => case StringLiteral(v) =>
if(v.indexOf("\n") != -1 && v.indexOf("\"\"\"") == -1) { if(v.count(c => c == '\n') >= 1 && v.length >= 80 && v.indexOf("\"\"\"") == -1) {
p"$dbquote$dbquote$dbquote$v$dbquote$dbquote$dbquote" p"$dbquote$dbquote$dbquote$v$dbquote$dbquote$dbquote"
} else { } else {
val escaped = v.replaceAll(dbquote, "\\\\\"").replaceAll("\n","\\n").replaceAll("\r","\\r") val escaped = v.replaceAll(dbquote, "\\\\\"").replaceAll("\n","\\n").replaceAll("\r","\\r")
......
...@@ -41,7 +41,7 @@ class ScalaPrinter(opts: PrinterOptions, ...@@ -41,7 +41,7 @@ class ScalaPrinter(opts: PrinterOptions,
case InfiniteIntegerLiteral(v) => p"BigInt($v)" case InfiniteIntegerLiteral(v) => p"BigInt($v)"
case StringLiteral(v) => case StringLiteral(v) =>
if(v.indexOf("\n") != -1 && v.indexOf("\"\"\"") == -1) { if(v.count(c => c == '\n') >= 1 && v.length >= 80 && v.indexOf("\"\"\"") == -1) {
p"$dbquote$dbquote$dbquote$v$dbquote$dbquote$dbquote" p"$dbquote$dbquote$dbquote$v$dbquote$dbquote$dbquote"
} else { } else {
val escaped = v.replaceAll(dbquote, "\\\\\"").replaceAll("\n","\\n").replaceAll("\r","\\r") val escaped = v.replaceAll(dbquote, "\\\\\"").replaceAll("\n","\\n").replaceAll("\r","\\r")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment