Skip to content

Commit

Permalink
Avoid indenting blank lines, to avoid trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
bensymonds committed Oct 8, 2014
1 parent b56947d commit ef5f9a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -383,7 +383,13 @@ abstract class AbstractGenerator[Code,TermName,TypeName](model: m.Model)


/** Helper methods for code generation */ /** Helper methods for code generation */
trait GeneratorHelpers[Code,TermName,TypeName]{ 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 */ /** Assemble doc comment with scala code */
def docWithCode(comment: String, code:Code): Code def docWithCode(comment: String, code:Code): Code
Expand Down
Expand Up @@ -8,7 +8,9 @@ import scala.slick.SlickException
trait OutputHelpers{ trait OutputHelpers{
def code: String 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 def indent(code: String): String


/** Writes given content to a file /** Writes given content to a file
Expand Down

0 comments on commit ef5f9a8

Please sign in to comment.