Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatTokens: fix getLastExceptParen, incl comment #4568

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class FormatTokens(leftTok2tok: Map[TokenHash, Int])(val arr: Array[FT])

def getLastExceptParen(tree: Tree): FT = {
val tokens = tree.tokens
val last = getLastNonTrivial(tokens, tree)
getClosingIfWithinParens(last)(getHead(tokens, tree)).getOrElse(last)
val last = getLast(tokens, tree)
getClosingIfWithinParens(prevNonComment(last))(getHead(tokens, tree))
.getOrElse(last)
}

final def findTokenWith[A](ft: FT, iter: FT => FT)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

class CommunitySpark3_5Suite extends CommunitySparkSuite("spark-3.5") {

override protected def totalStatesVisited: Option[Int] = Some(91352350)
override protected def totalStatesVisited: Option[Int] = Some(91352348)

override protected def builds =
Seq(getBuild("v3.5.3", dialects.Scala213, 2756))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7603,3 +7603,23 @@ object a {
.match
case _ =>
}
<<< match with dot, trailing case comment
object a:
b.c.match
case d if e => f
// comment
>>>
object a:
b.c.match
case d if e => f
// comment
<<< match without dot, trailing case comment
object a:
b.c match
case d if e => f
// comment
>>>
object a:
b.c match
case d if e => f
// comment
Original file line number Diff line number Diff line change
Expand Up @@ -7311,3 +7311,23 @@ object a {
(a.b(c)).match
case _ =>
}
<<< match with dot, trailing case comment
object a:
b.c.match
case d if e => f
// comment
>>>
object a:
b.c.match
case d if e => f
// comment
<<< match without dot, trailing case comment
object a:
b.c match
case d if e => f
// comment
>>>
object a:
b.c match
case d if e => f
// comment
Original file line number Diff line number Diff line change
Expand Up @@ -7630,3 +7630,23 @@ object a {
(a.b(c)).match
case _ =>
}
<<< match with dot, trailing case comment
object a:
b.c.match
case d if e => f
// comment
>>>
object a:
b.c.match
case d if e => f
// comment
<<< match without dot, trailing case comment
object a:
b.c match
case d if e => f
// comment
>>>
object a:
b.c match
case d if e => f
// comment
Original file line number Diff line number Diff line change
Expand Up @@ -7919,3 +7919,26 @@ object a {
(a.b(c)).match
case _ =>
}
<<< match with dot, trailing case comment
object a:
b.c.match
case d if e => f
// comment
>>>
object a:
b.c
.match
case d if e =>
f
// comment
<<< match without dot, trailing case comment
object a:
b.c match
case d if e => f
// comment
>>>
object a:
b.c match
case d if e =>
f
// comment
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,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, 1083470, "total explored")
assertEquals(explored, 1083760, "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