All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fix.IsEmptyNonEmpty.scala Maven / Gradle / Ivy

The newest version!
package fix

import scala.meta.Term
import scala.meta.Term.ApplyUnary
import scala.meta.XtensionCollectionLikeUI
import scalafix.Patch
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import scalafix.v1.XtensionSeqPatch

class IsEmptyNonEmpty extends SyntacticRule("IsEmptyNonEmpty") {
  override def fix(implicit doc: SyntacticDocument): Patch = {
    doc.tree.collect {
      case t @ ApplyUnary(Term.Name("!"), Term.Select(obj, Term.Name("isEmpty"))) =>
        Patch.replaceTree(t, s"${obj}.nonEmpty")
      case t @ ApplyUnary(Term.Name("!"), Term.Select(obj, Term.Name("nonEmpty"))) =>
        Patch.replaceTree(t, s"${obj}.isEmpty")
    }.asPatch
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy