Skip to content

Commit

Permalink
Merge pull request #1548 from scalameta/revert-empty-lines
Browse files Browse the repository at this point in the history
Revert avoidEmptyLinesAroundBlock feature
  • Loading branch information
poslegm authored Nov 11, 2019
2 parents 6083ee1 + e388e9a commit 778c75f
Show file tree
Hide file tree
Showing 23 changed files with 41 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ case class ScalafmtConfig(
continuationIndent.callSite,
continuationIndent.defnSite
)

val avoidEmptyLinesAroundBlock: Boolean =
edition > Edition(2019, 10)
}

object ScalafmtConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ class Router(formatOps: FormatOps) {
selfAnnotation.nonEmpty
val nl: Modification =
if (isSelfAnnotation) newlines2Modification(formatToken)
else if (style.avoidEmptyLinesAroundBlock) NewlineT()
else NewlineT(shouldGet2xNewlines(tok, style, owners))

val (startsLambda, lambdaPolicy, lambdaArrow, lambdaIndent) =
Expand Down Expand Up @@ -348,11 +347,6 @@ class Router(formatOps: FormatOps) {
)
}

case FormatToken(_, T.RightBrace(), _)
if style.avoidEmptyLinesAroundBlock && newlines > 1 =>
Seq(
Split(NoSplit, 0)
)
case FormatToken(_, T.RightBrace(), _) =>
Seq(
Split(xmlSpace(rightOwner), 0),
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/default/Advanced.stat
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ callStatement = js.If(genIsInstanceOf(callTrg, rtClass.tpe), {
rawApply
} else {
val reflBoxClassPatched = {

def isIntOrLongKind(kind: TypeKind) = kind match {
case _: INT | LONG => true
case _ => false
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/default/Apply.stat
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class ResolutionCopier(x: Int) {
}
>>>
class ResolutionCopier(x: Int) {

def visitClassDeclaration(node: ClassDeclaration): Boolean = {
val toNode = this._toNode.asInstanceOf[ClassDeclaration];
javaBooleanAnd(
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/default/Class.stat
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MediaStream() extends EventTarget {
}
>>>
class MediaStream() extends EventTarget {

/**
*/
val ended: Boolean = js.native
Expand Down
5 changes: 5 additions & 0 deletions scalafmt-tests/src/test/resources/default/Comment.stat
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
>>>
{

def cancel(reason: Any): js.Promise[Any] = js.native // comment

/**
Expand All @@ -28,6 +29,7 @@ object KeyValue {
}
>>>
object KeyValue {

// ================================
// 6.3.1 Special Key Values

Expand All @@ -43,6 +45,7 @@ object KeyValue {
}
>>>
object KeyValue {

// comment
/** This key value */
final val Unidentified = "Unidentified"
Expand Down Expand Up @@ -71,6 +74,7 @@ object D {
}
>>>
object D {

private val decompressedPrefixes: Seq[(String, String)] =
compressedPrefixes map { case (a, b) => (b, a) }

Expand All @@ -90,6 +94,7 @@ object Primes {
}
>>>
object Primes {

// prime sieve; use instead of the test or stream when you know the
// upper bound of the primes you will need.
// en.wikipedia.org/wiki/Sieve_of_Eratosthenes
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/default/DefDef.stat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object a {
}
>>>
object a {

/**
* Returns True is this state will always return better formatting than other.
*/
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/default/Fidelity.source
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object ScalaJSGroupID {
}
>>>
object ScalaJSGroupID {

def auto_impl(c: Context { type PrefixType = ScalaJSGroupID })()
: Expr[CrossGroupArtifactID] = {
reify {}
Expand Down
4 changes: 4 additions & 0 deletions scalafmt-tests/src/test/resources/default/Idempotency.stat
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ val bindingFuture = Http().bindAndHandleSync({
>>>
{
{

{
{
{
Expand All @@ -102,6 +103,7 @@ val bindingFuture = Http().bindAndHandleSync({
}
}
}

}
<<< rendering #339
{{
Expand All @@ -128,6 +130,7 @@ val bindingFuture = Http().bindAndHandleSync({
RequestRenderingContext(request, hostHeader, sendEntityTrigger)
}
}

})
}
}
Expand Down Expand Up @@ -166,6 +169,7 @@ val bindingFuture = Http().bindAndHandleSync({
})
new ResponseParsingMerge(rootParser)
}

})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ object A {
}
>>>
object A {

/** test */
def foo(): Int = 0
// bar
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ object a {
}
>>>
object a {

val x: Int => String = {
case 2 =>
"two"
case _ =>
"other"
}

}
<<< case clauses with stuff
object a {
Expand All @@ -39,6 +41,7 @@ object a {
}
>>>
object a {

val x: Int => String = {
case 2 =>
println("TWO")
Expand All @@ -47,6 +50,7 @@ object a {
// Nice
"other"
}

}
<<< case clauses to unit
object a {
Expand All @@ -62,10 +66,12 @@ object a {
}
>>>
object a {

val x: Int => Unit = {
case 0 =>
case 1 =>
case 2 =>
case _ => println("?")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ object a {
}
>>>
object a {

def x(i: Int): String =
if (i == 0)
"zero"
else if (i < 0)
"sub-zero"
else
"other"

}
<<< if-else with stuff
object a {
Expand All @@ -48,6 +50,7 @@ object a {
}
>>>
object a {

def x(i: Int): String =
if (i == 0)
/* what */
Expand Down Expand Up @@ -85,6 +88,7 @@ object a {
}
>>>
object a {

val x: Int => Unit =
if (i == 0)
println("zero")
Expand All @@ -94,6 +98,7 @@ object a {
def y(i: Int) =
if (i > 0)
println("yes!")

}
<<< nested if
object a {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private[test] sealed trait Test {
}

private[test] final object Tests {

protected[Tests] final case object Test1 extends Test {
final implicit override lazy val name: String = "foo"
}
Expand Down Expand Up @@ -65,6 +66,7 @@ private[test] sealed trait Test {
}

private[test] final object Tests {

protected[Tests] final case object Test1 extends Test {
final implicit override lazy val name: String = "foo"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sealed private[test] trait Test {
}

final private[test] object Tests {

final private type T1 = Int
final private type T2 = String

Expand Down Expand Up @@ -77,6 +78,7 @@ sealed private[test] trait Test {
}

final private[test] object Tests {

final private type T1 = Int
final private type T2 = String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private[test] sealed trait Test {
}

private[test] final object Tests {

protected[Tests] final case object Test1 extends Test {
final implicit override lazy val name: String = "foo"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ object Hase {
import play.api.libs.json.{ JsObject, JsString, Json }

object Hase {

def name(xs: OtherObject): String = {
s"Hallo ${xs.name}"
}

}
<<< import
import a.b.{c => d}
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/test/JavaDoc.stat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ val y = 2
}
>>>
object a {

/**
* Y is cool
*/
Expand Down
2 changes: 2 additions & 0 deletions scalafmt-tests/src/test/resources/test/i1439.stat
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ bar should endWith("st")
}
>>>
class TestSpec extends FlatSpec with Matchers {

"Foo" should "do things" in {
def bar: String = "test"
bar should endWith("st")
}

}
<<< test
object test {
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/unit/Advanced.source
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
x + y
})
object a extends b with c {

def foo[T: Int#Double#Triple,
R <% String](
@annot1
Expand Down
2 changes: 2 additions & 0 deletions scalafmt-tests/src/test/resources/unit/Basic.source
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ object a {
def two = 2 }
>>>
object a {

def one = 1

def two = 2
Expand All @@ -23,6 +24,7 @@ object a {
def two = 2 }
>>>
object a {

/**
* One
*/
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/unit/ColumnWidth.source
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ object Object {
}
>>>
object Object {

object A { a }
object B_________________________ {
b123456
Expand Down
1 change: 1 addition & 0 deletions scalafmt-tests/src/test/resources/unit/DefDef.stat
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ def heyImCool = {
>>>
def heyImCool = {
val c = b.foobar

}

0 comments on commit 778c75f

Please sign in to comment.