-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
scalafix-core/src/main/scala/scalafix/rewrite/DottyVarArgPattern.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package scalafix.rewrite | ||
|
||
import scala.meta._ | ||
|
||
import scala.meta.tokens.Token | ||
import scalafix.Patch | ||
|
||
case object DottyVarArgPattern extends Rewrite { | ||
override def rewrite(ctx: RewriteCtx): Patch = { | ||
val patches = ctx.tree.collect { | ||
case bind @ Pat.Bind(_, Pat.Arg.SeqWildcard()) => | ||
ctx.tokenList.leading(bind.tokens.last).collectFirst { | ||
case tok @ Token.At() => | ||
ctx.replaceToken(tok, ":") | ||
}.asPatch | ||
} | ||
patches.asPatch | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
scalafix-tests/input/src/main/scala/test/DottyVarArgPattern.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
rewrites = DottyVarArgPattern | ||
*/ | ||
package test | ||
|
||
object DottyVarArgPattern { | ||
List(1, 2, 3, 4) match { | ||
case List(1, 2, xs @ _*) => | ||
} | ||
|
||
val List(1, 2, x @ _*) = List(1, 2, 3, 4) | ||
} |
9 changes: 9 additions & 0 deletions
9
scalafix-tests/output-dotty/src/main/scala/test/DottyVarArgPattern.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test | ||
|
||
object DottyVarArgPattern { | ||
List(1, 2, 3, 4) match { | ||
case List(1, 2, xs : _*) => | ||
} | ||
|
||
val List(1, 2, x : _*) = List(1, 2, 3, 4) | ||
} |