diff --git a/api/shared/src/main/scala/play/twirl/api/BaseScalaTemplate.scala b/api/shared/src/main/scala/play/twirl/api/BaseScalaTemplate.scala index 60685755..70718d2b 100644 --- a/api/shared/src/main/scala/play/twirl/api/BaseScalaTemplate.scala +++ b/api/shared/src/main/scala/play/twirl/api/BaseScalaTemplate.scala @@ -10,7 +10,6 @@ import scala.collection.JavaConverters import scala.reflect.ClassTag case class BaseScalaTemplate[T <: Appendable[T], F <: Format[T]](format: F) { - // The overloaded methods are here for speed. The compiled templates // can take advantage of them for a 12% performance boost def _display_(x: AnyVal): T = format.escape(x.toString) diff --git a/api/shared/src/main/scala/play/twirl/api/Content.scala b/api/shared/src/main/scala/play/twirl/api/Content.scala index 19c06d53..bff75540 100644 --- a/api/shared/src/main/scala/play/twirl/api/Content.scala +++ b/api/shared/src/main/scala/play/twirl/api/Content.scala @@ -9,7 +9,6 @@ import scala.collection.immutable * Generic type representing content to be sent over an HTTP response. */ trait Content { - /** * The content String. */ @@ -19,7 +18,6 @@ trait Content { * The default Content type to use for this content. */ def contentType: String - } /** @@ -67,5 +65,4 @@ abstract class BufferedContent[A <: BufferedContent[A]]( } override def hashCode(): Int = this.getClass.hashCode() + body.hashCode() - } diff --git a/api/shared/src/main/scala/play/twirl/api/Formats.scala b/api/shared/src/main/scala/play/twirl/api/Formats.scala index 6c3cc6b5..33b2c28c 100644 --- a/api/shared/src/main/scala/play/twirl/api/Formats.scala +++ b/api/shared/src/main/scala/play/twirl/api/Formats.scala @@ -72,7 +72,6 @@ class Html private[api] (elements: immutable.Seq[Html], text: String, escape: Bo * Helper for HTML utility methods. */ object Html { - /** * Creates an HTML fragment with initial content specified. */ @@ -92,7 +91,6 @@ object Html { * Formatter for HTML content. */ object HtmlFormat extends Format[Html] { - /** * Creates a raw (unescaped) HTML fragment. */ @@ -114,7 +112,6 @@ object HtmlFormat extends Format[Html] { * Create an HTML Fragment that holds other fragments. */ def fill(elements: immutable.Seq[Html]): Html = new Html(elements) - } /** @@ -134,21 +131,18 @@ class Txt private (elements: immutable.Seq[Txt], text: String) extends BufferedC * Helper for utilities Txt methods. */ object Txt { - /** * Creates a text fragment with initial content specified. */ def apply(text: String): Txt = { new Txt(text) } - } /** * Formatter for text content. */ object TxtFormat extends Format[Txt] { - /** * Create a text fragment. */ @@ -168,7 +162,6 @@ object TxtFormat extends Format[Txt] { * Create an Txt Fragment that holds other fragments. */ def fill(elements: immutable.Seq[Txt]): Txt = new Txt(elements) - } /** @@ -188,21 +181,18 @@ class Xml private (elements: immutable.Seq[Xml], text: String) extends BufferedC * Helper for XML utility methods. */ object Xml { - /** * Creates an XML fragment with initial content specified. */ def apply(text: String): Xml = { new Xml(text) } - } /** * Formatter for XML content. */ object XmlFormat extends Format[Xml] { - /** * Creates an XML fragment. */ @@ -222,7 +212,6 @@ object XmlFormat extends Format[Xml] { * Create an XML Fragment that holds other fragments. */ def fill(elements: immutable.Seq[Xml]): Xml = new Xml(elements) - } /** @@ -243,7 +232,6 @@ class JavaScript private (elements: immutable.Seq[JavaScript], text: String) * Helper for JavaScript utility methods. */ object JavaScript { - /** * Creates a JavaScript fragment with initial content specified */ @@ -256,7 +244,6 @@ object JavaScript { * Formatter for JavaScript content. */ object JavaScriptFormat extends Format[JavaScript] { - /** * Integrate `text` without performing any escaping process. * @param text Text to integrate @@ -278,5 +265,4 @@ object JavaScriptFormat extends Format[JavaScript] { * Create an JavaScript Fragment that holds other fragments. */ def fill(elements: immutable.Seq[JavaScript]): JavaScript = new JavaScript(elements) - } diff --git a/api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala b/api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala index 3bbe71ed..66089d77 100644 --- a/api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala +++ b/api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala @@ -7,7 +7,6 @@ import scala.language.implicitConversions @deprecated("Use TwirlDefaultImports instead", "1.2.0") object TemplateMagic { - // --- UTILS def defining[T](t: T)(handler: T => Any) = { @@ -47,11 +46,9 @@ object TemplateMagic { // --- DATE class RichDate(date: java.util.Date) { - def format(pattern: String) = { new java.text.SimpleDateFormat(pattern).format(date) } - } implicit def richDate(date: java.util.Date) = new RichDate(date) @@ -59,16 +56,13 @@ object TemplateMagic { // --- STRING class RichString(string: String) { - def when(predicate: => Boolean) = { predicate match { case true => string case false => "" } } - } implicit def richString(string: String) = new RichString(string) - } diff --git a/api/shared/src/main/scala/play/twirl/api/TwirlFeatureImports.scala b/api/shared/src/main/scala/play/twirl/api/TwirlFeatureImports.scala index 235fffe2..7abda28f 100644 --- a/api/shared/src/main/scala/play/twirl/api/TwirlFeatureImports.scala +++ b/api/shared/src/main/scala/play/twirl/api/TwirlFeatureImports.scala @@ -16,7 +16,6 @@ import scala.language.implicitConversions * - default values (maybeFoo ? defaultFoo) */ object TwirlFeatureImports { - /** * Provides the `@defining` language feature, that lets you set a local val that can be reused. * diff --git a/api/shared/src/main/scala/play/twirl/api/TwirlHelperImports.scala b/api/shared/src/main/scala/play/twirl/api/TwirlHelperImports.scala index bdee1c68..d269dcf6 100644 --- a/api/shared/src/main/scala/play/twirl/api/TwirlHelperImports.scala +++ b/api/shared/src/main/scala/play/twirl/api/TwirlHelperImports.scala @@ -9,7 +9,6 @@ import scala.language.implicitConversions * Imports for useful Twirl helpers. */ object TwirlHelperImports { - /** Allows Java collections to be used as if they were Scala collections. */ implicit def twirlJavaCollectionToScala[T](x: java.lang.Iterable[T]): Iterable[T] = { import scala.collection.JavaConverters._ @@ -18,23 +17,18 @@ object TwirlHelperImports { /** Allows inline formatting of java.util.Date */ implicit class TwirlRichDate(date: java.util.Date) { - def format(pattern: String): String = { new java.text.SimpleDateFormat(pattern).format(date) } - } /** Adds a when method to Strings to control when they are rendered. */ implicit class TwirlRichString(string: String) { - def when(predicate: => Boolean): String = { predicate match { case true => string case false => "" } } - } - } diff --git a/api/shared/src/main/scala/play/twirl/api/package.scala b/api/shared/src/main/scala/play/twirl/api/package.scala index 89212565..a2f4aedc 100644 --- a/api/shared/src/main/scala/play/twirl/api/package.scala +++ b/api/shared/src/main/scala/play/twirl/api/package.scala @@ -6,7 +6,6 @@ package play.twirl import scala.reflect.ClassTag package object api { - /** * Brings the template engine as a [[http://docs.scala-lang.org/overviews/core/string-interpolation.html string interpolator]]. * @@ -22,7 +21,6 @@ package object api { * Three interpolators are available: `html`, `xml` and `js`. */ implicit class StringInterpolation(val sc: StringContext) extends AnyVal { - def html(args: Any*): Html = interpolate(args, HtmlFormat) def xml(args: Any*): Xml = interpolate(args, XmlFormat) @@ -43,7 +41,5 @@ package object api { } new BaseScalaTemplate[A, Format[A]](format)._display_(array) } - } - } diff --git a/api/shared/src/main/scala/play/twirl/api/utils/StringEscapeUtils.scala b/api/shared/src/main/scala/play/twirl/api/utils/StringEscapeUtils.scala index 1ad4f157..9ab24122 100644 --- a/api/shared/src/main/scala/play/twirl/api/utils/StringEscapeUtils.scala +++ b/api/shared/src/main/scala/play/twirl/api/utils/StringEscapeUtils.scala @@ -4,7 +4,6 @@ package play.twirl.api.utils object StringEscapeUtils { - def escapeEcmaScript(input: String): String = { val s = new StringBuilder() val len = input.length @@ -57,5 +56,4 @@ object StringEscapeUtils { s.toString() } - } diff --git a/api/shared/src/test/scala/play/twirl/api/test/BufferedContentSpec.scala b/api/shared/src/test/scala/play/twirl/api/test/BufferedContentSpec.scala index c7ceb00d..81329141 100644 --- a/api/shared/src/test/scala/play/twirl/api/test/BufferedContentSpec.scala +++ b/api/shared/src/test/scala/play/twirl/api/test/BufferedContentSpec.scala @@ -10,9 +10,7 @@ import play.twirl.api._ import scala.collection.immutable class BufferedContentSpec extends WordSpec with MustMatchers { - "equality checking" should { - "return false for BufferedContents with the same body but different implementations" in { Html("hello") must not be Xml("hello") Html("hello") must not be Txt("hello") @@ -54,7 +52,5 @@ class BufferedContentSpec extends WordSpec with MustMatchers { Txt("hello") mustEqual Txt("hello") Xml("hello") mustEqual Xml("hello") } - } - } diff --git a/api/shared/src/test/scala/play/twirl/api/test/FormatSpec.scala b/api/shared/src/test/scala/play/twirl/api/test/FormatSpec.scala index 6994545a..574f45c9 100644 --- a/api/shared/src/test/scala/play/twirl/api/test/FormatSpec.scala +++ b/api/shared/src/test/scala/play/twirl/api/test/FormatSpec.scala @@ -8,7 +8,6 @@ import org.scalatest.MustMatchers import org.scalatest.WordSpec class FormatSpec extends WordSpec with MustMatchers { - "Formats" should { "show null text values as empty" in { val text: String = null @@ -50,5 +49,4 @@ class FormatSpec extends WordSpec with MustMatchers { JavaScriptFormat.escape("""foo ' bar " baz \""").body must be("""foo \' bar \" baz \\""") } } - } diff --git a/api/shared/src/test/scala/play/twirl/api/test/StringInterpolationSpec.scala b/api/shared/src/test/scala/play/twirl/api/test/StringInterpolationSpec.scala index 7a1417df..379cb1a2 100644 --- a/api/shared/src/test/scala/play/twirl/api/test/StringInterpolationSpec.scala +++ b/api/shared/src/test/scala/play/twirl/api/test/StringInterpolationSpec.scala @@ -12,7 +12,6 @@ import org.scalatest.MustMatchers import org.scalatest.WordSpec class StringInterpolationSpec extends WordSpec with MustMatchers { - "StringInterpolation" should { "leave string parts untouched" in { val p = html"
"
@@ -38,5 +37,4 @@ class StringInterpolationSpec extends WordSpec with MustMatchers {
html"${javaList}".body mustBe "ab"
}
}
-
}
diff --git a/compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala b/compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala
index 64436275..f1bf7986 100644
--- a/compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala
+++ b/compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala
@@ -13,7 +13,6 @@ import play.twirl.parser.TwirlIO
import play.twirl.parser.TwirlParser
object Hash {
-
def apply(bytes: Array[Byte], imports: collection.Seq[String]): String = {
import java.security.MessageDigest
val digest = MessageDigest.getInstance("SHA-1")
@@ -22,14 +21,12 @@ object Hash {
imports.foreach(i => digest.update(i.getBytes("utf-8")))
digest.digest().map(0xFF & _).map { "%02x".format(_) }.foldLeft("") { _ + _ }
}
-
}
case class TemplateCompilationError(source: File, message: String, line: Int, column: Int)
extends RuntimeException(message)
object MaybeGeneratedSource {
-
def unapply(source: File): Option[GeneratedSource] = apply(source, TwirlIO.defaultCodec)
def apply(source: File, codec: Codec): Option[GeneratedSource] = {
@@ -40,7 +37,6 @@ object MaybeGeneratedSource {
None
}
}
-
}
sealed trait AbstractGeneratedSource {
@@ -117,7 +113,6 @@ sealed trait AbstractGeneratedSource {
}
case class GeneratedSource(file: File, codec: Codec = TwirlIO.defaultCodec) extends AbstractGeneratedSource {
-
def content = TwirlIO.readFileAsString(file, codec)
def needRecompilation(imports: collection.Seq[String]): Boolean =
@@ -150,7 +145,6 @@ case class GeneratedSource(file: File, codec: Codec = TwirlIO.defaultCodec) exte
file.delete()
}
}
-
}
case class GeneratedSourceVirtual(path: String) extends AbstractGeneratedSource {
@@ -162,7 +156,6 @@ case class GeneratedSourceVirtual(path: String) extends AbstractGeneratedSource
}
object TwirlCompiler {
-
val DefaultImports = Seq(
"_root_.play.twirl.api.TwirlFeatureImports._",
"_root_.play.twirl.api.TwirlHelperImports._",
@@ -395,7 +388,6 @@ object TwirlCompiler {
}
def templateCode(template: Template, resultType: String): collection.Seq[Any] = {
-
val defs = (template.sub ++ template.defs).map {
case t: Template if t.name.toString == "" => templateCode(t, resultType)
case t: Template => {
@@ -490,7 +482,6 @@ package """ :+ packageName :+ """
}
object TemplateAsFunctionCompiler {
-
// Note, the presentation compiler is not thread safe, all access to it must be synchronized. If access to it
// is not synchronized, then weird things happen like FreshRunReq exceptions are thrown when multiple sub projects
// are compiled (done in parallel by default by SBT). So if adding any new methods to this object, make sure you
@@ -521,7 +512,6 @@ package """ :+ packageName :+ """
private val Timeout = 10000
def getFunctionMapping(signature: String, returnType: String): (String, String, String) = synchronized {
-
def filterType(t: String) =
t.replace("_root_.scala.").body + TextFormat.escape("Hello
").body
text must be("Hello
")
-
}
}
}
diff --git a/parser/src/main/scala/play/twirl/parser/TwirlIO.scala b/parser/src/main/scala/play/twirl/parser/TwirlIO.scala
index ba12aa8b..df2c3ddb 100644
--- a/parser/src/main/scala/play/twirl/parser/TwirlIO.scala
+++ b/parser/src/main/scala/play/twirl/parser/TwirlIO.scala
@@ -13,7 +13,6 @@ import java.net.URL
* This is intentionally not public API.
*/
private[twirl] object TwirlIO {
-
val defaultEncoding = scala.util.Properties.sourceEncoding
val defaultCodec = Codec(defaultEncoding)
diff --git a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala
index 663613e8..9663d901 100644
--- a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala
+++ b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala
@@ -89,7 +89,6 @@ import scala.util.parsing.input.OffsetPosition
* - Invalid ("alone") '@' symbols.
*/
class TwirlParser(val shouldParseInclusiveDot: Boolean) {
-
import play.twirl.parser.TreeNodes._
import scala.util.parsing.input.Positional
@@ -983,7 +982,6 @@ class TwirlParser(val shouldParseInclusiveDot: Boolean) {
Success(template, input)
else
Error(template, input, errorStack.toList)
-
}
def mkRegressionStatisticsString(): Unit = {
diff --git a/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala b/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala
index 3c2cdc7b..e0b8122c 100644
--- a/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala
+++ b/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala
@@ -10,7 +10,6 @@ import org.scalatest.WordSpec
import play.twirl.parser.TreeNodes._
class ParserSpec extends WordSpec with MustMatchers with Inside {
-
val parser = new TwirlParser(shouldParseInclusiveDot = false)
def get(templateName: String): String = {
@@ -56,9 +55,7 @@ class ParserSpec extends WordSpec with MustMatchers with Inside {
}
"New twirl parser" should {
-
"succeed for" when {
-
"static.scala.html" in {
parseSuccess("static.scala.html")
}
@@ -169,7 +166,6 @@ class ParserSpec extends WordSpec with MustMatchers with Inside {
}
"handle string literals within parentheses" when {
-
"with left parenthesis" in {
parseStringSuccess("""@foo("(")""")
}
@@ -177,7 +173,6 @@ class ParserSpec extends WordSpec with MustMatchers with Inside {
"with right parenthesis and '@'" in {
parseStringSuccess("""@foo(")@")""")
}
-
}
"handle escaped closing curly braces" in {
@@ -185,7 +180,6 @@ class ParserSpec extends WordSpec with MustMatchers with Inside {
}
"fail for" when {
-
"unclosedBracket.scala.html" in {
parseFailure("unclosedBracket.scala.html", "Expected '}' but found 'EOF'", 12, 6)
}
@@ -197,9 +191,6 @@ class ParserSpec extends WordSpec with MustMatchers with Inside {
"invalidAt.scala.html" in {
parseFailure("invalidAt.scala.html", "Invalid '@' symbol", 5, 5)
}
-
}
-
}
-
}
diff --git a/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateCompilerErrorHandler.scala b/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateCompilerErrorHandler.scala
index 2ee7e27d..60de0e1c 100644
--- a/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateCompilerErrorHandler.scala
+++ b/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateCompilerErrorHandler.scala
@@ -10,7 +10,6 @@ import sbt.internal.inc.LoggedReporter
import scala.io.Codec
trait TemplateCompilerErrorHandler {
-
def handleError(log: Logger, codec: Codec): PartialFunction[Throwable, Nothing] = {
case TemplateCompilationError(source, message, line, column) =>
val exception = TemplateProblem.exception(source, codec, message, line, column)
diff --git a/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateProblem.scala b/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateProblem.scala
index 4efd4be1..8bdece07 100644
--- a/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateProblem.scala
+++ b/sbt-twirl/src/main/scala-sbt-1.0/play/twirl/sbt/TemplateProblem.scala
@@ -15,7 +15,6 @@ import xsbti.Severity
import scala.io.Codec
object TemplateProblem {
-
def positionMapper(codec: Codec): Position => Option[Position] = position => {
toScala(position.sourceFile).flatMap(f => MaybeGeneratedSource(f, codec)).map { generated =>
TemplatePosition(generated, position)
diff --git a/sbt-twirl/src/main/scala/play/twirl/sbt/SbtTwirl.scala b/sbt-twirl/src/main/scala/play/twirl/sbt/SbtTwirl.scala
index af1df5cb..ba41a033 100644
--- a/sbt-twirl/src/main/scala/play/twirl/sbt/SbtTwirl.scala
+++ b/sbt-twirl/src/main/scala/play/twirl/sbt/SbtTwirl.scala
@@ -28,7 +28,6 @@ object Import {
}
object SbtTwirl extends AutoPlugin {
-
import Import.TwirlKeys._
val autoImport = Import
diff --git a/sbt-twirl/src/main/scala/play/twirl/sbt/TemplateCompiler.scala b/sbt-twirl/src/main/scala/play/twirl/sbt/TemplateCompiler.scala
index 33ec45dc..f9c32d4c 100644
--- a/sbt-twirl/src/main/scala/play/twirl/sbt/TemplateCompiler.scala
+++ b/sbt-twirl/src/main/scala/play/twirl/sbt/TemplateCompiler.scala
@@ -43,7 +43,6 @@ object TemplateCompiler extends TemplateCompilerErrorHandler {
codec: Codec,
log: Logger
): Seq[File] = {
-
try {
syncGenerated(targetDirectory, codec)
val templates = collectTemplates(sourceDirectories, templateFormats, includeFilter, excludeFilter)
diff --git a/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplateMappingSpec.scala b/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplateMappingSpec.scala
index bdfa91a6..a2130272 100644
--- a/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplateMappingSpec.scala
+++ b/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplateMappingSpec.scala
@@ -11,9 +11,7 @@ import play.twirl.sbt.TemplateProblem.TemplateMapping
import play.twirl.sbt.TemplateProblem.TemplateMapping.Location
class TemplateMappingSpec extends WordSpec with MustMatchers with Inspectors {
-
"TemplateMapping" should {
-
"handle empty templates" in {
val mapping = TemplateMapping(Seq.empty)
diff --git a/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplatePositionSpec.scala b/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplatePositionSpec.scala
index ce5585db..7fd22498 100644
--- a/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplatePositionSpec.scala
+++ b/sbt-twirl/src/test/scala/play/twirl/sbt/test/TemplatePositionSpec.scala
@@ -12,11 +12,8 @@ import org.scalatest.MustMatchers
import org.scalatest.WordSpec
class TemplatePositionSpec extends WordSpec with MustMatchers with Inspectors {
-
"TemplatePosition" should {
-
"toString" should {
-
"have the source path" in {
val file = new File("/some/path/file.scala.html")
val location = TemplateMapping.Location(line = 10, column = 2, offset = 22, content = "some content")
@@ -71,5 +68,4 @@ class TemplatePositionSpec extends WordSpec with MustMatchers with Inspectors {
}
}
}
-
}