Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalafmt formatting #290

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions api/shared/src/main/scala/play/twirl/api/Content.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import scala.collection.immutable
* Generic type representing content to be sent over an HTTP response.
*/
trait Content {

/**
* The content String.
*/
Expand All @@ -19,7 +18,6 @@ trait Content {
* The default Content type to use for this content.
*/
def contentType: String

}

/**
Expand Down Expand Up @@ -67,5 +65,4 @@ abstract class BufferedContent[A <: BufferedContent[A]](
}

override def hashCode(): Int = this.getClass.hashCode() + body.hashCode()

}
14 changes: 0 additions & 14 deletions api/shared/src/main/scala/play/twirl/api/Formats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -92,7 +91,6 @@ object Html {
* Formatter for HTML content.
*/
object HtmlFormat extends Format[Html] {

/**
* Creates a raw (unescaped) HTML fragment.
*/
Expand All @@ -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)

}

/**
Expand All @@ -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.
*/
Expand All @@ -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)

}

/**
Expand All @@ -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.
*/
Expand All @@ -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)

}

/**
Expand All @@ -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
*/
Expand All @@ -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
Expand All @@ -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)

}
6 changes: 0 additions & 6 deletions api/shared/src/main/scala/play/twirl/api/TemplateMagic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) = {
Expand Down Expand Up @@ -47,28 +46,23 @@ 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)

// --- STRING

class RichString(string: String) {

def when(predicate: => Boolean) = {
predicate match {
case true => string
case false => ""
}
}

}

implicit def richString(string: String) = new RichString(string)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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 => ""
}
}

}

}
4 changes: 0 additions & 4 deletions api/shared/src/main/scala/play/twirl/api/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]].
*
Expand All @@ -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)
Expand All @@ -43,7 +41,5 @@ package object api {
}
new BaseScalaTemplate[A, Format[A]](format)._display_(array)
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package play.twirl.api.utils

object StringEscapeUtils {

def escapeEcmaScript(input: String): String = {
val s = new StringBuilder()
val len = input.length
Expand Down Expand Up @@ -57,5 +56,4 @@ object StringEscapeUtils {

s.toString()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -54,7 +52,5 @@ class BufferedContentSpec extends WordSpec with MustMatchers {
Txt("hello") mustEqual Txt("hello")
Xml("hello") mustEqual Xml("hello")
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,5 +49,4 @@ class FormatSpec extends WordSpec with MustMatchers {
JavaScriptFormat.escape("""foo ' bar " baz \""").body must be("""foo \' bar \" baz \\""")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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"<p>"
Expand All @@ -38,5 +37,4 @@ class StringInterpolationSpec extends WordSpec with MustMatchers {
html"${javaList}".body mustBe "ab"
}
}

}
Loading