Skip to content

Commit

Permalink
Update default preference to Prevent instead of Preserve.
Browse files Browse the repository at this point in the history
Add back in TODOs (tests still broken).
  • Loading branch information
jkinkead committed Jun 14, 2016
1 parent ec83f83 commit 3386885
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 76 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -549,7 +549,7 @@ Otherwise, if ``false``, spaces before arguments will always be removed.
danglingCloseParenthesis
~~~~~~~~~~~~~~~~~~~~~~~~

Default: ``Preserve``
Default: ``Prevent``

If ``Force``, any closing parentheses will be set to dangle. For example:

Expand Down
Expand Up @@ -201,7 +201,7 @@ case object PreserveDanglingCloseParenthesis extends BooleanPreferenceDescriptor
case object DanglingCloseParenthesis extends IntentPreferenceDescriptor {
val key = "danglingCloseParenthesis"
val description = "Put a newline before a ')' in an argument expression"
val defaultValue = Preserve
val defaultValue = Prevent
}

case object SpaceInsideParentheses extends BooleanPreferenceDescriptor {
Expand Down
Expand Up @@ -55,19 +55,20 @@ class DoubleIndentMethodFormatterTest extends AbstractFormatterTest {
"""def foo(
| a: String)"""

// TODO: Broken until https://github.com/scala-ide/scalariform/issues/187 is fixed.
"""def foo(a: String,
| b: String)""" =/=>
"""def foo(
| a: String,
| b: String)"""

// TODO: Broken until https://github.com/scala-ide/scalariform/issues/187 is fixed.
"""def foo(a: String,
| b: String
|)""" =/=>
"""def foo(
| a: String,
| b: String
|)"""
| b: String)"""

"""def foo(a: String, b: String,
| c: String)""" ==>
Expand Down
Expand Up @@ -311,8 +311,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
|if (b) c
|)""" ==>
"""a(
| if (b) c
|)"""
| if (b) c)"""

"""a(
|if (b)
Expand Down Expand Up @@ -408,8 +407,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
|)""" ==>
"""(
| 42,
| 46
|)""" // I prefer no initial indent for tuples, although you could argue it should be consistent with ParenExprs
| 46)""" // I prefer no initial indent for tuples, although you could argue it should be consistent with ParenExprs

"""a(b,
|c => {
Expand Down Expand Up @@ -444,8 +442,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
"""Book(
| name = "Name",
| author = "Author",
| rating = 5
|)"""
| rating = 5)"""

"""foobar(
|(1,2),
Expand Down Expand Up @@ -686,9 +683,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| label("label"),
| popupMenu(
| viewer( // TODO
| )
| )
|)"""
| )))"""

"""a(b)
|.c(d)
Expand Down Expand Up @@ -743,8 +738,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| i => List.range(1, i) map (j => (i, j))
|)""" ==>
"""List.range(1, r) flatMap (
| i => List.range(1, i) map (j => (i, j))
|)"""
| i => List.range(1, i) map (j => (i, j)))"""

"""a map {
| b =>
Expand Down Expand Up @@ -799,12 +793,10 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
"""a(
| b,
| c,
| d
|)(
| d)(
| e,
| f,
| g
|)"""
| g)"""

{
implicit val formattingPreferences = FormattingPreferences.setPreference(AlignArguments, true)
Expand Down Expand Up @@ -856,14 +848,11 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| zzz(
| a,
| b,
| c
| )
| ),
| c)),
| c(firstGroupOne(x)),
| d,
| e,
| f
|)"""
| f)"""

"""o.manyArguments(
| abc = 0,
Expand All @@ -879,8 +868,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| abcTwo,
| abcThree = 3,
| abcFour = 4,
| abcFive = 3
|)"""
| abcFive = 3)"""

"""Nested1(abcccc = 1,
| abc2 = 2,
Expand All @@ -889,8 +877,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
"""Nested1(
| abcccc = 1,
| abc2 = 2,
| abcThree = 3
|)"""
| abcThree = 3)"""

"""o.grouped(
| firstGroupOne = 1,
Expand All @@ -910,8 +897,7 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| secondGroup2 = "Two",
|
| thirdGroupOne = 3,
| thirdGroup2 = Three(3)
|)"""
| thirdGroup2 = Three(3))"""

"""multiClause(
| arg1 = 1,
Expand All @@ -924,13 +910,10 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
|)""" ==>
"""multiClause(
| arg1 = 1,
| argument2 = 2
|)(
| argument2 = 2)(
| args3 = 3,
| arg4 = 4
|)(
| arg5 = 5
|)"""
| arg4 = 4)(
| arg5 = 5)"""

"""a(
|b = c
Expand All @@ -940,11 +923,9 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
|)(
|d)""" ==>
"""a(
| b = c
|)(
| b = c)(
| c,
| d
|)(
| d)(
| d)"""

"""Nested0(
Expand All @@ -961,14 +942,11 @@ class MiscExpressionFormatterTest extends AbstractExpressionFormatterTest {
| arg1 = Nested1(
| abcccc = 1,
| abc2 = 2,
| abcThree = 3
| ),
| abcThree = 3),
| NestedTwo(
| abcccc = 1,
| abc2 = 2,
| abcThree = 3
| )
|)"""
| abcThree = 3))"""
}
override val debug = false
}
Expand Up @@ -10,8 +10,7 @@ class MiscFormatterTest extends AbstractFormatterTest {
|)""" ==>
"""class Foo(
| bar: String,
| baz: String
|)"""
| baz: String)"""

"""class Foo(
| bar: String,
Expand Down
Expand Up @@ -34,8 +34,7 @@ class ParenAndBracketSpacingTest extends AbstractExpressionFormatterTest {
| beta = bar match {
| case _ => "bar"
| },
| gamma = false
|)"""
| gamma = false)"""

"""foo(
|alpha = "foo",
Expand All @@ -47,10 +46,8 @@ class ParenAndBracketSpacingTest extends AbstractExpressionFormatterTest {
"""foo(
| alpha = "foo",
| beta = bar(
| a = 1
| ),
| gamma = false
|)"""
| a = 1),
| gamma = false)"""

"""foo(
|arg = bar(
Expand All @@ -59,9 +56,7 @@ class ParenAndBracketSpacingTest extends AbstractExpressionFormatterTest {
|)""" ==>
"""foo(
| arg = bar(
| baz = "a"
| ).xyz
|)"""
| baz = "a").xyz)"""
}

{
Expand Down
Expand Up @@ -99,8 +99,7 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
| case b =>
| val c = { d: Int => 1 }
| 1.toString
| }
| )
| })
|}"""

"""class C1492 {
Expand Down Expand Up @@ -350,15 +349,13 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
"""def A(
| a: A ⇒ B = null,
| bee: ⇒ B = null,
| c: B ⇒ C = null
|): D"""
| c: B ⇒ C = null): D"""

"""class a(
| b: Int
|)""" ==>
"""class a(
| b: Int
|)"""
| b: Int)"""

"""class a(
| a: String = "",
Expand Down Expand Up @@ -424,8 +421,7 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
"""private def executeWithinClient[T](
| crawlerConfig: String => JsValue = Fancy.function,
| f: HttpCrawlerClient => T,
| port: Int = SpecHelper.port
|): T"""
| port: Int = SpecHelper.port): T"""

// By name parameters have correct spacing
"""def a(
Expand All @@ -434,17 +430,15 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
|): A""" ==>
"""def a(
| p1: => (SomeLongByNameParam => SomeShorterParam) = Null,
| param2: SomeShorterParam = Null
|): A"""
| param2: SomeShorterParam = Null): A"""

// Formats parameterized types correctly
"""def A(complicatedType: Option[B ,C, D[E, F,G]] = None,
| simpleType: String = ""
|): B""" ==>
"""def A(
| complicatedType: Option[B, C, D[E, F, G]] = None,
| simpleType: String = ""
|): B"""
| simpleType: String = ""): B"""

// Param gets placed onto a new line due to current limitations of existing IntertokenFormatInstructions
"""case class Spacing(param: Int = 1,
Expand All @@ -454,8 +448,7 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
"""case class Spacing(
| param: Int = 1,
| paramTwo: Int = 2,
| paramThree: String = "3"
|)"""
| paramThree: String = "3")"""

// Groups and formats consecutive single line parameters (multi line params)
"""case class Spacing(param: Int = 1,
Expand Down Expand Up @@ -487,8 +480,7 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
| paramTwo: Int = 2,
|
| paramFour: Option[String] = Some("One"),
| paramFive: Any = Nothing
|)"""
| paramFive: Any = Nothing)"""

// Aligns implicits and curried parameters properly
"""class SomeClass(
Expand All @@ -504,10 +496,8 @@ implicit val formattingPreferences = FormattingPreferences.setPreference(SpacesW
"""class SomeClass(
| parameterOne: Int = 1,
| val parameterTwo: Option[String] = None,
| three: String = "three"
|)(
| intermediate: Int
|)(
| three: String = "three")(
| intermediate: Int)(
| implicit
| val four: Int,
| five: String,
Expand Down

0 comments on commit 3386885

Please sign in to comment.