Skip to content

Commit

Permalink
Router: force NL in ; case of braceless match
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 5, 2024
1 parent ec9f91f commit d99ed9c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class FormatTokens(leftTok2tok: Map[TokenHash, Int])(val arr: Array[FormatToken]
getDelimsIfEnclosed(tree).map(_._2)

def isEnclosedInMatching(tokens: Tokens, tree: Tree): Boolean =
getHeadIfEnclosed(tokens, tree).isDefined
getDelimsIfEnclosed(tokens, tree).isDefined
def isEnclosedInMatching(tree: Tree): Boolean =
isEnclosedInMatching(tree.tokens, tree)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,14 @@ class Router(formatOps: FormatOps) {
// New statement
case FormatToken(_: T.Semicolon, _, StartsStatementRight(stmt))
if !stmt.is[Term.EndMarker] =>
val noSpace = !style.newlines.okSpaceForSource(newlines) ||
style.dialect.allowSignificantIndentation &&
stmt.is[Case] && stmt.parent.forall {
case p: Tree.Block => !isEnclosedInMatching(p)
case _ => false
}
Seq(
Split(!style.newlines.okSpaceForSource(newlines), 0)(Space)
Split(noSpace, 0)(Space)
.withSingleLine(endOfSingleLineBlock(getLast(stmt))),
// For some reason, this newline cannot cost 1.
Split(Newline2x(ft), 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class CommunityScala3Suite(name: String)

class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") {

override protected def totalStatesVisited: Option[Int] = Some(32288017)
override protected def totalStatesVisited: Option[Int] = Some(32288009)

override protected def builds = Seq(getBuild("3.2.2", dialects.Scala32, 791))

}

class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") {

override protected def totalStatesVisited: Option[Int] = Some(34858906)
override protected def totalStatesVisited: Option[Int] = Some(34858898)

override protected def builds = Seq(getBuild("3.3.3", dialects.Scala33, 861))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7239,12 +7239,7 @@ tag match
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
>>>
test does not parse: [dialect scala3] `outdent` expected but `case` found
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE; case _ =>
^
====== full result: ======
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE; case _ =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1497994, "total explored")
assertEquals(explored, 1498031, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down

0 comments on commit d99ed9c

Please sign in to comment.