Class/Object

org.scalafmt.config

Newlines

Related Docs: object Newlines | package config

Permalink

case class Newlines(source: SourceHints = Newlines.classic, neverInResultType: Boolean = false, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, alwaysBeforeTopLevelStatements: Boolean = false, afterCurlyLambda: NewlineCurlyLambda = NewlineCurlyLambda.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, alwaysBeforeMultilineDef: Boolean = true, afterInfix: Option[AfterInfix] = None, afterInfixBreakOnNested: Boolean = false, afterInfixMaxCountPerExprForSome: Int = 10, afterInfixMaxCountPerFile: Int = 500, 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.

alwaysBeforeCurlyBraceLambdaParams

If true, puts a newline after the open brace and the parameters list of an anonymous function. 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.

afterCurlyLambda

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 //...

alwaysBeforeMultilineDef

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

// newlines.alwaysBeforeMultilineDef = false
def foo(bar: Bar): Foo = bar
  .flatMap(f)
  .map(g)
// newlines.alwaysBeforeMultilineDef = true
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

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, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Newlines
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Newlines(source: SourceHints = Newlines.classic, neverInResultType: Boolean = false, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, topLevelStatementsMinBreaks: Int = 1, topLevelStatements: Seq[BeforeAfter] = Seq.empty, alwaysBeforeTopLevelStatements: Boolean = false, afterCurlyLambda: NewlineCurlyLambda = NewlineCurlyLambda.never, implicitParamListModifierForce: Seq[BeforeAfter] = Seq.empty, implicitParamListModifierPrefer: Option[BeforeAfter] = None, alwaysBeforeElseAfterCurlyIf: Boolean = false, alwaysBeforeMultilineDef: Boolean = true, afterInfix: Option[AfterInfix] = None, afterInfixBreakOnNested: Boolean = false, afterInfixMaxCountPerExprForSome: Int = 10, afterInfixMaxCountPerFile: Int = 500, avoidAfterYield: Boolean = true)

    Permalink

    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.

    alwaysBeforeCurlyBraceLambdaParams

    If true, puts a newline after the open brace and the parameters list of an anonymous function. 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.

    afterCurlyLambda

    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 //...

    alwaysBeforeMultilineDef

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

    // newlines.alwaysBeforeMultilineDef = false
    def foo(bar: Bar): Foo = bar
      .flatMap(f)
      .map(g)
    // newlines.alwaysBeforeMultilineDef = true
    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

    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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val afterCurlyLambda: NewlineCurlyLambda

    Permalink

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

    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 }
  5. val afterInfix: Option[AfterInfix]

    Permalink

    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

  6. val afterInfixBreakOnNested: Boolean

    Permalink

    Force breaks around nested (enclosed in parentheses) expressions

  7. val afterInfixMaxCountPerExprForSome: Int

    Permalink

    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.

  8. val afterInfixMaxCountPerFile: Int

    Permalink

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

  9. val alwaysBeforeCurlyBraceLambdaParams: Boolean

    Permalink

    If true, puts a newline after the open brace and the parameters list of an anonymous function.

    If true, puts a newline after the open brace and the parameters list of an anonymous function. For example something.map { n => consume(n) }

  10. val alwaysBeforeElseAfterCurlyIf: Boolean

    Permalink

    if true, add a new line between the end of a curly if and the following else.

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

  11. val alwaysBeforeMultilineDef: Boolean

    Permalink

    If true, add a newline before the body of a multiline def without curly braces.

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

    // newlines.alwaysBeforeMultilineDef = false
    def foo(bar: Bar): Foo = bar
      .flatMap(f)
      .map(g)
    // newlines.alwaysBeforeMultilineDef = true
    def foo(bar: Bar): Foo =
      bar
        .flatMap(f)
        .map(g)
  12. val alwaysBeforeTopLevelStatements: Boolean

    Permalink
  13. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  14. val avoidAfterYield: Boolean

    Permalink

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

    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 {
        ...
      }
  15. val breakAfterInfix: AfterInfix

    Permalink
  16. def checkInfixConfig(infixCount: Int): Newlines

    Permalink
  17. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. lazy val forceAfterImplicitParamListModifier: Boolean

    Permalink
  21. lazy val forceBeforeImplicitParamListModifier: Boolean

    Permalink
  22. lazy val forceBlankAfterMultilineTopLevelStmt: Boolean

    Permalink
  23. lazy val forceBlankBeforeMultilineTopLevelStmt: Boolean

    Permalink
  24. val formatInfix: Boolean

    Permalink
  25. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  26. val implicitParamListModifierForce: Seq[BeforeAfter]

    Permalink
  27. val implicitParamListModifierPrefer: Option[BeforeAfter]

    Permalink
  28. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. val neverBeforeJsNative: Boolean

    Permalink

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

  31. val neverInResultType: Boolean

    Permalink
  32. lazy val notBeforeImplicitParamListModifier: Boolean

    Permalink
  33. lazy val notPreferAfterImplicitParamListModifier: Boolean

    Permalink
  34. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  35. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  36. val penalizeSingleSelectMultiArgList: Boolean

    Permalink

    If true, adds a penalty to newlines before a dot starting a select chain of length one and argument list.

    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.

  37. val reader: ConfDecoder[Newlines]

    Permalink
  38. val sometimesBeforeColonInMethodReturnType: Boolean

    Permalink

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

  39. val source: SourceHints

    Permalink

    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

  40. val sourceIgnored: Boolean

    Permalink
  41. def sourceIn(hints: SourceHints*): Boolean

    Permalink
    Annotations
    @inline()
  42. def sourceIs(hint: SourceHints): Boolean

    Permalink
    Annotations
    @inline()
  43. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  44. val topLevelStatements: Seq[BeforeAfter]

    Permalink

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

  45. val topLevelStatementsMinBreaks: Int

    Permalink

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

  46. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped