Skip to content

Commit

Permalink
EtaExpansionRewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Dec 24, 2023
1 parent 5481434 commit febc3b6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rules/src/main/scala/fix/EtaExpansionRewrite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fix

import scala.meta.Term
import scalafix.Patch
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import scala.meta.tokens.Token

class EtaExpansionRewrite extends SyntacticRule("EtaExpansionRewrite") {
override def fix(implicit doc: SyntacticDocument): Patch = {
doc.tree.collect { case t @ Term.Eta(x) =>
t.tokens.reverseIterator.find(_.is[Token.Underscore]).filter(_.start > x.pos.end).map(Patch.removeToken).asPatch
}.asPatch
}
}

0 comments on commit febc3b6

Please sign in to comment.