Skip to content

Commit

Permalink
RedundantBraces: keep around do-while within for
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 28, 2024
1 parent 23b5c7a commit 6a01184
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,15 @@ class RedundantBraces(implicit val ftoks: FormatTokens)
case p: Term.Match => p.expr eq b
case p: Type.Match => p.tpe eq b

case p: Term.ForClause if p.body eq b =>
@tailrec
def iter(t: Tree): Boolean = t match {
case _: Term.Do => true
case Term.Block(x :: Nil) => iter(x)
case _ => false
}
iter(stat)

case parent => SyntacticGroupOps.groupNeedsParenthesis(
TreeSyntacticGroup(parent),
TreeSyntacticGroup(stat),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2071,20 +2071,15 @@ for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
} while (launchedTask)
}
>>>
test does not parse: [dialect scala213] `end of file` expected but `while` found
availableCpus,
tasks
) while (launchedTask)
^
====== full result: ======
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels)
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
}
<<< #4133 do-while within for, extra block
rewrite.redundantBraces.maxLines = 100
===
Expand All @@ -2095,17 +2090,12 @@ for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {{
} while (launchedTask)
}}
>>>
test does not parse: [dialect scala213] `end of file` expected but `while` found
availableCpus,
tasks
) while (launchedTask)
^
====== full result: ======
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels)
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
do launchedTask = resourceOfferSingleTaskSet(
taskSet,
maxLocality,
shuffledOffers,
availableCpus,
tasks
) while (launchedTask)
}

0 comments on commit 6a01184

Please sign in to comment.