Skip to content

Commit

Permalink
Router: skip braces-to-parens policy if had NL
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 21, 2024
1 parent 2ff744b commit 693c16e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,8 @@ class FormatOps(
case Decision(`beforeClose`, ss) => ss
.flatMap(s => if (s.isNL) None else Some(s.withMod(NoSplit)))
}
SpaceOrNoSplit(end) -> policy
SpaceOrNoSplit(end) ->
Policy.RelayOnSplit((s, _) => s.isNL)(policy, NoPolicy)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7393,4 +7393,17 @@ processTreeOpt(s) { s match
Some(parseClasslike(c))
}
>>>
FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[131] parseClasslike ( >>> Ident(parseClasslike) [427..441) | LeftParen [441..442) >>> Term.Name [427..441) | Term.ArgClause [441..444) <<<[]>>>', line 9: exceeded `runner.maxStateVisits`=1000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded]
processTreeOpt(s) { s match
case td: TypeDef
if !td.symbol.flags.is(Flags.Synthetic) && (!td.symbol.flags
.is(Flags.Case) || !td.symbol.flags.is(Flags.Enum)) =>
Some(parseTypeDef(td, c))

case vd: ValDef
if !isSyntheticField(vd.symbol) && (!vd.symbol.flags
.is(Flags.Case) || !vd.symbol.flags.is(Flags.Enum)) =>
Some(parseValDef(c, vd))

case c: ClassDef if c.symbol.shouldDocumentClasslike =>
Some(parseClasslike(c))
}
Original file line number Diff line number Diff line change
Expand Up @@ -7422,4 +7422,19 @@ processTreeOpt(s) { s match
Some(parseClasslike(c))
}
>>>
FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[121] ClassDef if >>> Ident(ClassDef) [368..376) | KwIf [377..379) >>> Type.Name [368..376) | Case.CaseImpl [360..445) <<<[ ]>>>', line 8: exceeded `runner.maxStateVisits`=1000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded]
processTreeOpt(s) { s match
case td: TypeDef
if !td.symbol.flags.is(Flags.Synthetic) && (!td.symbol.flags.is(
Flags.Case
) || !td.symbol.flags.is(Flags.Enum)) =>
Some(parseTypeDef(td, c))

case vd: ValDef
if !isSyntheticField(vd.symbol) && (!vd.symbol.flags.is(
Flags.Case
) || !vd.symbol.flags.is(Flags.Enum)) =>
Some(parseValDef(c, vd))

case c: ClassDef if c.symbol.shouldDocumentClasslike =>
Some(parseClasslike(c))
}

0 comments on commit 693c16e

Please sign in to comment.