Skip to content

Commit

Permalink
Simplify denotation lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Jacobowitz committed Oct 5, 2017
1 parent 562bef9 commit eebcf02
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions scalafix/rules/src/main/scala/fix/Cats_v1_0_0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,8 @@ case class ContraMapToLMap(index: SemanticdbIndex)
val unApplyName = "catsUnapply2left"

ctx.tree.collect {
case Term.Apply(fun, _) =>
if (contraMatcher.matches(fun) &&
fun.children.headOption.flatMap(index.denotation).exists(_.name == unApplyName )) {
fun.children.find(contraMatcher.matches).map(tree => ctx.replaceTree(tree, "lmap")).getOrElse(Patch.empty)
} else {
Patch.empty
}
case _ => Patch.empty

case Term.Apply(Term.Select(f, contraMatcher(contramap)), _) if f.denotation.exists(_.name == unApplyName) =>
ctx.replaceTree(contramap, "lmap")
}.asPatch
}
}
Expand Down

0 comments on commit eebcf02

Please sign in to comment.