case class Newlines(source: SourceHints = Newlines.classic, avoidInResultType: Boolean = false, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, beforeCurlyLambdaParams: BeforeCurlyLambdaParams = BeforeCurlyLambdaParams.never, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, alwaysBeforeTopLevelStatements: Boolean = false, afterCurlyLambdaParams: AfterCurlyLambdaParams = AfterCurlyLambdaParams.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, alwaysBeforeMultilineDef: Boolean = false, beforeMultiline: Option[SourceHints] = None, beforeMultilineDef: Option[SourceHints] = None, afterInfix: Option[AfterInfix] = None, afterInfixBreakOnNested: Boolean = false, afterInfixMaxCountPerExprForSome: Int = 10, afterInfixMaxCountPerFile: Int = 500, avoidForSimpleOverflow: Seq[AvoidForSimpleOverflow] = Seq.empty, avoidAfterYield: Boolean = true) extends Product with Serializable

source

Controls how line breaks in the input source are handled If classic (default), the old mixed behaviour will be used If keep, try to keep source newlines If fold, ignore source and try to remove line breaks If unfold, ignore source and try to break lines

neverBeforeJsNative

If true, a newline will never be placed in front of js.native.

sometimesBeforeColonInMethodReturnType

If true, scalafmt may choose to put a newline before colon : at defs.

penalizeSingleSelectMultiArgList

If true, adds a penalty to newlines before a dot starting a select chain of length one and argument list. The penalty matches the number of arguments to the select chain application.

// If true, favor
logger.elem(a,
            b,
            c)
// instead of
logger
  .elem(a, b, c)

// penalty is proportional to argument count, example:
logger.elem(a, b, c)    // penalty 2
logger.elem(a, b, c, d) // penalty 3, etc.

If false, matches pre-v0.5 behavior. Note. this option may be removed in a future release.

beforeCurlyLambdaParams

  • if Never, tries to use a space between the opening curly brace and the list of parameters of anonymous functions, and some partial functions (those with a single case clause and no conditions)
  • if MultilineWithCaseOnly, forces a newline in partial functions (see above) which can't be formatted on a single line
  • if Always, forces a newline in lambda and partial functions. For example:
something.map {
  n =>
    consume(n)
}
topLevelStatementsMinBreaks

Minimum span (number of line breaks between first and last line) to start forcing blank lines.

topLevelStatements

Forces a blank line before and/or after a top-level statement.

afterCurlyLambdaParams

If never (default), it will remove any extra lines below curly lambdas

something.map { x =>

  f(x)
}

will become

something.map { x =>
  f(x)
}

If always, it will always add one empty line (opposite of never). If preserve, and there isn't an empty line, it will keep it as it is. If there is one or more empty lines, it will place a single empty line. If squash, it will try to squash lambda body in one line:

xs.map { x =>
  x + 1
}

will become

xs.map { x => x + 1 }
alwaysBeforeElseAfterCurlyIf

if true, add a new line between the end of a curly if and the following else. For example if(someCond) { // ... } else //...

beforeMultilineDef

If unfold (or true), add a newline before the body of a multiline def without curly braces. See #1126 for discussion. For example,

// newlines.beforeMultilineDef = fold
def foo(bar: Bar): Foo = bar
  .flatMap(f)
  .map(g)

// newlines.beforeMultilineDef = unfold
def foo(bar: Bar): Foo =
  bar
    .flatMap(f)
    .map(g)
afterInfix

Controls how line breaks around operations are handled If keep (default for source=classic,keep), preserve existing If some (default for source=fold), break after some infix ops If many (default for source=unfold), break after many infix ops

afterInfixBreakOnNested

Force breaks around nested (enclosed in parentheses) expressions

afterInfixMaxCountPerExprForSome

Switch to many for a given expression (possibly nested) if the number of operations in that expression exceeds this value AND afterInfix had been set to some.

afterInfixMaxCountPerFile

Switch to keep for a given file if the total number of infix operations in that file exceeds this value

avoidForSimpleOverflow

  • punct: don't force break if overflow is only due to trailing punctuation
  • tooLong: don't force break if overflow is due to tokens which are too long and would likely overflow even after a break
avoidAfterYield

If false (legacy behavior), inserts unconditional line break after yield if the yield body doesn't fit on a single line. For example,

// newlines.avoidAfterYield = true (default)
for (a <- as)
yield Future {
  ...
}

// newlines.avoidAfterYield = false (default before v2).
for (a <- as)
yield
  Future {
    ...
  }
Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Newlines
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Newlines(source: SourceHints = Newlines.classic, avoidInResultType: Boolean = false, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, beforeCurlyLambdaParams: BeforeCurlyLambdaParams = BeforeCurlyLambdaParams.never, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, alwaysBeforeTopLevelStatements: Boolean = false, afterCurlyLambdaParams: AfterCurlyLambdaParams = AfterCurlyLambdaParams.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, alwaysBeforeMultilineDef: Boolean = false, beforeMultiline: Option[SourceHints] = None, beforeMultilineDef: Option[SourceHints] = None, afterInfix: Option[AfterInfix] = None, afterInfixBreakOnNested: Boolean = false, afterInfixMaxCountPerExprForSome: Int = 10, afterInfixMaxCountPerFile: Int = 500, avoidForSimpleOverflow: Seq[AvoidForSimpleOverflow] = Seq.empty, avoidAfterYield: Boolean = true)

    source

    Controls how line breaks in the input source are handled If classic (default), the old mixed behaviour will be used If keep, try to keep source newlines If fold, ignore source and try to remove line breaks If unfold, ignore source and try to break lines

    neverBeforeJsNative

    If true, a newline will never be placed in front of js.native.

    sometimesBeforeColonInMethodReturnType

    If true, scalafmt may choose to put a newline before colon : at defs.

    penalizeSingleSelectMultiArgList

    If true, adds a penalty to newlines before a dot starting a select chain of length one and argument list. The penalty matches the number of arguments to the select chain application.

    // If true, favor
    logger.elem(a,
                b,
                c)
    // instead of
    logger
      .elem(a, b, c)
    
    // penalty is proportional to argument count, example:
    logger.elem(a, b, c)    // penalty 2
    logger.elem(a, b, c, d) // penalty 3, etc.

    If false, matches pre-v0.5 behavior. Note. this option may be removed in a future release.

    beforeCurlyLambdaParams

    • if Never, tries to use a space between the opening curly brace and the list of parameters of anonymous functions, and some partial functions (those with a single case clause and no conditions)
    • if MultilineWithCaseOnly, forces a newline in partial functions (see above) which can't be formatted on a single line
    • if Always, forces a newline in lambda and partial functions. For example:
    something.map {
      n =>
        consume(n)
    }
    topLevelStatementsMinBreaks

    Minimum span (number of line breaks between first and last line) to start forcing blank lines.

    topLevelStatements

    Forces a blank line before and/or after a top-level statement.

    afterCurlyLambdaParams

    If never (default), it will remove any extra lines below curly lambdas

    something.map { x =>
    
      f(x)
    }

    will become

    something.map { x =>
      f(x)
    }

    If always, it will always add one empty line (opposite of never). If preserve, and there isn't an empty line, it will keep it as it is. If there is one or more empty lines, it will place a single empty line. If squash, it will try to squash lambda body in one line:

    xs.map { x =>
      x + 1
    }

    will become

    xs.map { x => x + 1 }
    alwaysBeforeElseAfterCurlyIf

    if true, add a new line between the end of a curly if and the following else. For example if(someCond) { // ... } else //...

    beforeMultilineDef

    If unfold (or true), add a newline before the body of a multiline def without curly braces. See #1126 for discussion. For example,

    // newlines.beforeMultilineDef = fold
    def foo(bar: Bar): Foo = bar
      .flatMap(f)
      .map(g)
    
    // newlines.beforeMultilineDef = unfold
    def foo(bar: Bar): Foo =
      bar
        .flatMap(f)
        .map(g)
    afterInfix

    Controls how line breaks around operations are handled If keep (default for source=classic,keep), preserve existing If some (default for source=fold), break after some infix ops If many (default for source=unfold), break after many infix ops

    afterInfixBreakOnNested

    Force breaks around nested (enclosed in parentheses) expressions

    afterInfixMaxCountPerExprForSome

    Switch to many for a given expression (possibly nested) if the number of operations in that expression exceeds this value AND afterInfix had been set to some.

    afterInfixMaxCountPerFile

    Switch to keep for a given file if the total number of infix operations in that file exceeds this value

    avoidForSimpleOverflow

    • punct: don't force break if overflow is only due to trailing punctuation
    • tooLong: don't force break if overflow is due to tokens which are too long and would likely overflow even after a break
    avoidAfterYield

    If false (legacy behavior), inserts unconditional line break after yield if the yield body doesn't fit on a single line. For example,

    // newlines.avoidAfterYield = true (default)
    for (a <- as)
    yield Future {
      ...
    }
    
    // newlines.avoidAfterYield = false (default before v2).
    for (a <- as)
    yield
      Future {
        ...
      }

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val afterCurlyLambdaParams: AfterCurlyLambdaParams
  5. val afterInfix: Option[AfterInfix]
  6. val afterInfixBreakOnNested: Boolean
  7. val afterInfixMaxCountPerExprForSome: Int
  8. val afterInfixMaxCountPerFile: Int
  9. lazy val alwaysBeforeCurlyLambdaParams: Boolean
  10. val alwaysBeforeElseAfterCurlyIf: Boolean
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. val avoidAfterYield: Boolean
  13. val avoidForSimpleOverflow: Seq[AvoidForSimpleOverflow]
  14. lazy val avoidForSimpleOverflowPunct: Boolean
  15. lazy val avoidForSimpleOverflowTooLong: Boolean
  16. val avoidInResultType: Boolean
  17. val beforeCurlyLambdaParams: BeforeCurlyLambdaParams
  18. val breakAfterInfix: AfterInfix
  19. def checkInfixConfig(infixCount: Int): Newlines
  20. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  21. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  23. lazy val forceAfterImplicitParamListModifier: Boolean
  24. lazy val forceBeforeImplicitParamListModifier: Boolean
  25. lazy val forceBlankAfterMultilineTopLevelStmt: Boolean
  26. lazy val forceBlankBeforeMultilineTopLevelStmt: Boolean
  27. val formatInfix: Boolean
  28. lazy val getBeforeMultiline: SourceHints
  29. lazy val getBeforeMultilineDef: SourceHints
  30. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  31. val implicitParamListModifierForce: Seq[BeforeAfter]
  32. val implicitParamListModifierPrefer: Option[BeforeAfter]
  33. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. val neverBeforeJsNative: Boolean
  36. lazy val notBeforeImplicitParamListModifier: Boolean
  37. lazy val notPreferAfterImplicitParamListModifier: Boolean
  38. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  39. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  40. val penalizeSingleSelectMultiArgList: Boolean
  41. def productElementNames: Iterator[String]
    Definition Classes
    Product
  42. val reader: ConfDecoder[Newlines]
  43. val sometimesBeforeColonInMethodReturnType: Boolean
  44. val source: SourceHints
  45. def sourceIgnored: Boolean
    Annotations
    @inline()
  46. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  47. val topLevelStatements: Seq[BeforeAfter]
  48. val topLevelStatementsMinBreaks: Int
  49. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  50. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  51. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped