Skip to content

Commit

Permalink
AvoidInfix: don't duplicate RedundantParens logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jun 1, 2022
1 parent 37e606c commit 52d21c3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ class AvoidInfix(implicit ctx: RewriteCtx) extends RewriteSession {
builder += TokenPatch.AddRight(lhsLast, ")", keepTok = true)
}

// remove parens if enclosed
for {
parent <- tree.parent
if !parent.is[Term.ApplyInfix] && !parent.is[Term.Apply]
if ctx.style.rewrite.rules.contains(RedundantParens)
infixTokens = tree.tokens
head <- infixTokens.headOption if head.is[Token.LeftParen]
last <- infixTokens.lastOption if last.is[Token.RightParen]
if ctx.isMatching(head, last)
} yield {
builder += TokenPatch.Remove(head)
builder += TokenPatch.Remove(last)
}

ctx.addPatchSet(builder.result(): _*)

case _ =>
Expand Down
2 changes: 0 additions & 2 deletions scalafmt-tests/src/test/resources/rewrite/AvoidInfix.stat
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,5 @@ object a {
>>>
object a {
val foo = bar

a.baz(b)

}

0 comments on commit 52d21c3

Please sign in to comment.