Skip to content
Permalink
Browse files

Avoid indenting blank lines, to avoid trailing whitespace.

  • Loading branch information
bensymonds committed Oct 8, 2014
1 parent b56947d commit ef5f9a8eaffd03c45294dadbe7dbd1c1546bc6b8
@@ -383,7 +383,13 @@ abstract class AbstractGenerator[Code,TermName,TypeName](model: m.Model)

/** Helper methods for code generation */
trait GeneratorHelpers[Code,TermName,TypeName]{
def indent(code: String): String = code.split("\n").mkString("\n"+" ")
def indent(code: String): String = {
val lines = code.split("\n")
lines.tail.foldLeft(lines.head) { (out, line) =>
out + '\n' +
(if (line.isEmpty) line else " " + line)
}
}

/** Assemble doc comment with scala code */
def docWithCode(comment: String, code:Code): Code
@@ -8,7 +8,9 @@ import scala.slick.SlickException
trait OutputHelpers{
def code: String

/** Indents all but the first line of the given string */
/** Indents all but the first line of the given string.
* No indent is added to empty lines.
*/
def indent(code: String): String

/** Writes given content to a file

0 comments on commit ef5f9a8

Please sign in to comment.
You can’t perform that action at this time.