-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from olafurpg/replace-syntax
Harden sbt-scalafix
- Loading branch information
Showing
19 changed files
with
234 additions
and
140 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
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
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
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
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
42 changes: 27 additions & 15 deletions
42
scalafix-sbt/src/main/scala/scalafix/internal/sbt/ScalafixCompletions.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 |
---|---|---|
@@ -1,23 +1,35 @@ | ||
package scalafix.internal.sbt | ||
|
||
import java.io.File | ||
import sbt.complete.DefaultParsers | ||
import sbt.complete.DefaultParsers._ | ||
import sbt.complete.FileExamples | ||
import sbt.complete.Parser | ||
|
||
object ScalafixCompletions { | ||
val names = List( | ||
"NoValInForComprehension", | ||
"RemoveXmlLiterals", | ||
"VolatileLazyVal", | ||
"ProcedureSyntax", | ||
"ExplicitUnit", | ||
"DottyVarArgPattern", | ||
"ExplicitReturnTypes", | ||
"RemoveUnusedImports", | ||
"NoAutoTupling" | ||
) | ||
val parser = { | ||
val rewrite: Parser[String] = | ||
names.map(literal).reduceLeft(_ | _) | ||
(token(Space) ~> token(rewrite)).* <~ SpaceClass.* | ||
private val names = ScalafixRewriteNames.all | ||
|
||
private def uri(protocol: String) = | ||
token(protocol + ":") ~> NotQuoted.map(x => s"$protocol:$x") | ||
|
||
private def fileRewrite(base: File): Parser[String] = | ||
token("file:") ~> | ||
StringBasic | ||
.examples(new FileExamples(base)) | ||
.map(f => s"file:${new File(base, f).getAbsolutePath}") | ||
|
||
private val namedRewrite: Parser[String] = | ||
names.map(literal).reduceLeft(_ | _) | ||
|
||
def parser(base: File): Parser[Seq[String]] = { | ||
val all = | ||
namedRewrite | | ||
fileRewrite(base) | | ||
uri("github") | | ||
uri("replace") | | ||
uri("http") | | ||
uri("https") | | ||
uri("scala") | ||
(token(Space) ~> token(all)).* <~ SpaceClass.* | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
scalafix-sbt/src/main/scala/scalafix/internal/sbt/ScalafixRewriteNames.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,17 @@ | ||
// DO NOT EDIT: this file is generated by build.sbt | ||
package scalafix.internal.sbt | ||
|
||
object ScalafixRewriteNames { | ||
def all: List[String] = List( | ||
"DottyKeywords", | ||
"NoValInForComprehension", | ||
"RemoveXmlLiterals", | ||
"VolatileLazyVal", | ||
"ProcedureSyntax", | ||
"ExplicitUnit", | ||
"DottyVarArgPattern", | ||
"ExplicitReturnTypes", | ||
"RemoveUnusedImports", | ||
"NoAutoTupling" | ||
) | ||
} |
Oops, something went wrong.