case class Newlines(source: SourceHints = Newlines.classic, avoidInResultType: Boolean = false, beforeTypeBounds: SourceHints = Newlines.classic, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, beforeOpenParenDefnSite: Option[BeforeOpenParen] = None, beforeOpenParenCallSite: Option[BeforeOpenParen] = None, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, beforeCurlyLambdaParams: BeforeCurlyLambdaParams = BeforeCurlyLambdaParams.never, topLevelStatementBlankLines: Seq[TopStatBlanks] = Seq.empty, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, beforeTemplateBodyIfBreakInParentCtors: Boolean = false, topLevelBodyIfMinStatements: Seq[BeforeAfter] = Seq.empty, topLevelBodyMinStatements: Int = 2, afterCurlyLambdaParams: AfterCurlyLambdaParams = AfterCurlyLambdaParams.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, forceBeforeMultilineAssign: Option[ForceBeforeMultilineAssign] = None, alwaysBeforeMultilineDef: Boolean = false, beforeMultiline: Option[SourceHints] = None, beforeMultilineDef: Option[SourceHints] = None, selectChains: 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)
}
topLevelStatementBlankLines

Controls 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, beforeTypeBounds: SourceHints = Newlines.classic, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, beforeOpenParenDefnSite: Option[BeforeOpenParen] = None, beforeOpenParenCallSite: Option[BeforeOpenParen] = None, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, beforeCurlyLambdaParams: BeforeCurlyLambdaParams = BeforeCurlyLambdaParams.never, topLevelStatementBlankLines: Seq[TopStatBlanks] = Seq.empty, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, beforeTemplateBodyIfBreakInParentCtors: Boolean = false, topLevelBodyIfMinStatements: Seq[BeforeAfter] = Seq.empty, topLevelBodyMinStatements: Int = 2, afterCurlyLambdaParams: AfterCurlyLambdaParams = AfterCurlyLambdaParams.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, forceBeforeMultilineAssign: Option[ForceBeforeMultilineAssign] = None, alwaysBeforeMultilineDef: Boolean = false, beforeMultiline: Option[SourceHints] = None, beforeMultilineDef: Option[SourceHints] = None, selectChains: 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)
    }
    topLevelStatementBlankLines

    Controls 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 avoidForSimpleOverflowSLC: Boolean
  16. lazy val avoidForSimpleOverflowTooLong: Boolean
  17. val avoidInResultType: Boolean
  18. val beforeCurlyLambdaParams: BeforeCurlyLambdaParams
  19. val beforeMultilineDef: Option[SourceHints]
  20. val beforeTemplateBodyIfBreakInParentCtors: Boolean
  21. val beforeTypeBounds: SourceHints
  22. val breakAfterInfix: AfterInfix
  23. def checkInfixConfig(infixCount: Int): Newlines
  24. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  27. lazy val forceAfterImplicitParamListModifier: Boolean
  28. lazy val forceBeforeImplicitParamListModifier: Boolean
  29. lazy val forceBlankBeforeMultilineTopLevelStmt: Boolean
  30. val formatInfix: Boolean
  31. lazy val getBeforeMultiline: SourceHints
  32. def getBeforeOpenParenCallSite: Option[SourceHints]
  33. def getBeforeOpenParenDefnSite: Option[SourceHints]
  34. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  35. lazy val getSelectChains: SourceHints
  36. def getTopStatBlankLines(tree: Tree, numBreaks: Int, nest: Int): Option[NumBlanks]
  37. val implicitParamListModifierForce: Seq[BeforeAfter]
  38. val implicitParamListModifierPrefer: Option[BeforeAfter]
  39. def isBeforeOpenParenCallSite: Boolean
  40. def isBeforeOpenParenDefnSite: Boolean
  41. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  42. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  43. val neverBeforeJsNative: Boolean
  44. lazy val notBeforeImplicitParamListModifier: Boolean
  45. lazy val notPreferAfterImplicitParamListModifier: Boolean
  46. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  47. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  48. val penalizeSingleSelectMultiArgList: Boolean
  49. def productElementNames: Iterator[String]
    Definition Classes
    Product
  50. lazy val shouldForceBeforeMultilineAssign: ForceBeforeMultilineAssign
  51. val sometimesBeforeColonInMethodReturnType: Boolean
  52. val source: SourceHints
  53. def sourceIgnored: Boolean
    Annotations
    @inline()
  54. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  55. val topLevelBodyIfMinStatements: Seq[BeforeAfter]
  56. val topLevelBodyMinStatements: Int
  57. val topLevelStatements: Seq[BeforeAfter]
  58. val topLevelStatementsMinBreaks: Int
  59. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  60. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  61. 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