Skip to content

Commit 7ff8323

Browse files
authored
Merge pull request #128 from MasseGuillaume/roughly-apply-infix
Add ApplyInfix syntax for Roughly
2 parents 29c3a36 + a92fed5 commit 7ff8323

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

scalafix/input/src/main/scala/fix/RoughlySrc.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ object RoughlySrc {
2020
val d2 = 1L -> 1
2121
val multi = new m.HashMap[Int, m.Set[Int]] with m.MultiMap[Int, Int]
2222

23+
Map(d) mapValues (id) : i.Map[Int, Int]
24+
Map(d).mapValues(id) : i.Map[Int, Int]
2325
// i.SortedMap(d).mapValues(id): i.SortedMap[Int, Int]
2426
// m.SortedMap(d).mapValues(id): c.SortedMap[Int, Int]
2527
i.IntMap(d).mapValues(f2) : i.Map[Int, Int]
@@ -31,6 +33,8 @@ object RoughlySrc {
3133
multi.mapValues(f2) : c.Map[Int, Int]
3234
props.mapValues(id) : c.Map[String, String]
3335

36+
Map(d) filterKeys (f) : i.Map[Int, Int]
37+
Map(d).filterKeys(f) : i.Map[Int, Int]
3438
// i.SortedMap(d).filterKeys(f): i.SortedMap[Int, Int]
3539
// m.SortedMap(d).filterKeys(f): c.SortedMap[Int, Int]
3640
i.IntMap(d).filterKeys(f) : i.Map[Int, Int]

scalafix/output/src/main/scala/fix/RoughlySrc.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ object RoughlySrc {
1616
val d2 = 1L -> 1
1717
val multi = new m.HashMap[Int, m.Set[Int]] with m.MultiMap[Int, Int]
1818

19+
(Map(d) mapValues (id)).toMap : i.Map[Int, Int]
20+
Map(d).mapValues(id).toMap : i.Map[Int, Int]
1921
// i.SortedMap(d).mapValues(id): i.SortedMap[Int, Int]
2022
// m.SortedMap(d).mapValues(id): c.SortedMap[Int, Int]
2123
i.IntMap(d).mapValues(f2).toMap : i.Map[Int, Int]
@@ -27,6 +29,8 @@ object RoughlySrc {
2729
multi.mapValues(f2).toMap : c.Map[Int, Int]
2830
props.mapValues(id).toMap : c.Map[String, String]
2931

32+
(Map(d) filterKeys (f)).toMap : i.Map[Int, Int]
33+
Map(d).filterKeys(f).toMap : i.Map[Int, Int]
3034
// i.SortedMap(d).filterKeys(f): i.SortedMap[Int, Int]
3135
// m.SortedMap(d).filterKeys(f): c.SortedMap[Int, Int]
3236
i.IntMap(d).filterKeys(f).toMap : i.Map[Int, Int]

scalafix/rules/src/main/scala/fix/Roughly.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ final case class Roughly(index: SemanticdbIndex, config: RoughlyConfig)
6969

7070
val collectFixes =
7171
ctx.tree.collect {
72+
case ap @ Term.ApplyInfix(_, mapValues(_), _, _) if strictMapValues =>
73+
ctx.addLeft(ap, "(") +
74+
ctx.addRight(ap, ").toMap")
75+
7276
case ap @ Term.Apply(Term.Select(_, mapValues(_)), List(_)) if strictMapValues =>
7377
ctx.addRight(ap, ".toMap")
7478

79+
case ap @ Term.ApplyInfix(_, filterKeys(_), _, _) if strictFilterKeys =>
80+
ctx.addLeft(ap, "(") +
81+
ctx.addRight(ap, ").toMap")
82+
7583
case ap @ Term.Apply(Term.Select(_, filterKeys(_)), List(_)) if strictFilterKeys =>
7684
ctx.addRight(ap, ".toMap")
7785

0 commit comments

Comments
 (0)