Skip to content

Commit

Permalink
Router: refactor modification before (
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 12, 2023
1 parent f4c3ac4 commit 77cb5c2
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -671,24 +671,21 @@ class Router(formatOps: FormatOps) {
case _ => false
}
} =>
def modification: Modification = leftOwner match {
case _: Mod => Space
def modification: Modification = Space(leftOwner match {
case _ if left.is[T.Comment] => true
case _: Mod => true
// Add a space between constructor annotations and their parameter lists
// see:
// https://github.com/scalameta/scalafmt/pull/1516
// https://github.com/scalameta/scalafmt/issues/1528
case init: Init if init.parent.forall(_.is[Mod.Annot]) => Space
case t: Term.Name
if style.spaces.afterTripleEquals && t.value == "===" =>
Space
case name: Term.Name
if style.spaces.afterSymbolicDefs &&
isSymbolicName(name.value) && name.parent.exists(isDefDef) =>
Space
case _: Defn.ExtensionGroup if left.is[soft.KwExtension] =>
Space(style.spaces.afterKeywordBeforeParen)
case _ => Space(left.is[T.Comment])
}
case t: Init => t.parent.forall(_.is[Mod.Annot])
case t @ Term.Name(name) if isSymbolicName(name) =>
style.spaces.afterTripleEquals && name == "===" ||
style.spaces.afterSymbolicDefs && t.parent.exists(isDefDef)
case _: Defn.ExtensionGroup =>
style.spaces.afterKeywordBeforeParen && left.is[soft.KwExtension]
case _ => false
})
def baseNoSplit(implicit fileLine: FileLine) = Split(modification, 0)
val defn = isParamClauseSite(rightOwner)
val defRhs = if (defn) defDefBodyParent(rightOwner) else None
Expand Down

0 comments on commit 77cb5c2

Please sign in to comment.