-
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.
- Loading branch information
Showing
47 changed files
with
1,371 additions
and
320 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
imports.optimize = true |
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 @@ | ||
scalac -Ywarn-unused-import -Yrangepos -Xplugin:/Users/ollie/.ivy2/local/ch.epfl.scala/scalafix-nsc_2.11/0.2.0-SNAPSHOT/jars/scalafix-nsc_2.11.jar $1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package scalafix | ||
|
||
import scala.util.matching.Regex | ||
import scalafix.util.AbsoluteFile | ||
|
||
case class FilterMatcher(include: Regex, exclude: Regex) { | ||
def matches(file: AbsoluteFile): Boolean = matches(file.path) | ||
def matches(input: String): Boolean = | ||
include.findFirstIn(input).isDefined && | ||
exclude.findFirstIn(input).isEmpty | ||
} | ||
|
||
object FilterMatcher { | ||
val matchEverything = new FilterMatcher(".*".r, mkRegexp(Nil)) | ||
|
||
def mkRegexp(filters: Seq[String]): Regex = | ||
filters match { | ||
case Nil => "$a".r // will never match anything | ||
case head :: Nil => head.r | ||
case _ => filters.mkString("(", "|", ")").r | ||
} | ||
|
||
def apply(includes: Seq[String], excludes: Seq[String]): FilterMatcher = | ||
new FilterMatcher(mkRegexp(includes), mkRegexp(excludes)) | ||
def apply(include: String): FilterMatcher = | ||
new FilterMatcher(mkRegexp(Seq(include)), mkRegexp(Nil)) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package scalafix.rewrite | ||
import scalafix.ScalafixConfig | ||
import scalafix.util.AssociatedComments | ||
import scalafix.util.TokenList | ||
|
||
case class RewriteCtx( | ||
config: ScalafixConfig, | ||
tokenList: TokenList, | ||
comments: AssociatedComments, | ||
semantic: Option[SemanticApi] | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package scalafix | ||
|
||
import scala.meta.Importee | ||
import scala.meta.tokens.Token | ||
import scalafix.util.CanonicalImport | ||
import scalafix.util.ImportPatch | ||
import scalafix.util.logger | ||
|
||
import com.typesafe.config.Config | ||
|
||
package object syntax { | ||
implicit class XtensionImporter(i: CanonicalImport) { | ||
def supersedes(patch: ImportPatch): Boolean = | ||
i.ref.structure == patch.importer.ref.structure && | ||
(i.importee.is[Importee.Wildcard] || | ||
i.importee.structure == patch.importer.importee.structure) | ||
} | ||
|
||
implicit class XtensionToken(token: Token) { | ||
def posTuple: (Int, Int) = token.start -> token.end | ||
} | ||
|
||
implicit class XtensionConfig(config: Config) { | ||
def getBoolOrElse(key: String, els: Boolean): Boolean = | ||
if (config.hasPath(key)) config.getBoolean(key) | ||
else els | ||
} | ||
implicit class XtensionString(str: String) { | ||
def reveal: String = logger.reveal(str) | ||
} | ||
} |
Oops, something went wrong.