Skip to content

Commit

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

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

class WildcardTypeRewrite extends SyntacticRule("WildcardTypeRewrite") {
override def fix(implicit doc: SyntacticDocument): Patch = {
doc.tree.collect { case t: Type.Wildcard =>
t.tokens.find(_.is[Token.Underscore]).map(x => Patch.replaceToken(x, "?")).asPatch
}.asPatch
}
}

0 comments on commit d4eee69

Please sign in to comment.