public interface ScalafixArguments
To obtain an instance of ScalafixArguments, use Scalafix.newArguments().
Instances of ScalafixArguments are immutable and thread safe. It is safe to re-use the same
ScalafixArguments instance for multiple Scalafix invocations. *
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ScalafixRule> |
availableRules()
The rules that are valid arguments for
withRules(List). |
java.util.List<ScalafixRule> |
rulesThatWillRun()
The rules that would run when calling
run()
Takes into account rules that are configured in .scalafix.conf. |
ScalafixError[] |
run()
Run the Scalafix commmand-line interface
main function. |
java.util.Optional<ScalafixException> |
validate()
Validates that the passed arguments are valid.
|
ScalafixArguments |
withCharset(java.nio.charset.Charset charset) |
ScalafixArguments |
withClasspath(java.util.List<java.nio.file.Path> classpath) |
ScalafixArguments |
withConfig(java.util.Optional<java.nio.file.Path> config) |
ScalafixArguments |
withExcludedPaths(java.util.List<java.nio.file.PathMatcher> matchers) |
ScalafixArguments |
withMainCallback(ScalafixMainCallback callback) |
ScalafixArguments |
withMode(ScalafixMainMode mode) |
ScalafixArguments |
withParsedArguments(java.util.List<java.lang.String> args) |
ScalafixArguments |
withPaths(java.util.List<java.nio.file.Path> paths) |
ScalafixArguments |
withPrintStream(java.io.PrintStream out) |
ScalafixArguments |
withRules(java.util.List<java.lang.String> rules) |
ScalafixArguments |
withScalacOptions(java.util.List<java.lang.String> options) |
ScalafixArguments |
withScalaVersion(java.lang.String version) |
ScalafixArguments |
withSourceroot(java.nio.file.Path path) |
ScalafixArguments |
withToolClasspath(java.net.URLClassLoader toolClasspath) |
ScalafixArguments |
withWorkingDirectory(java.nio.file.Path path) |
ScalafixArguments withRules(java.util.List<java.lang.String> rules)
rules - The rules passed via the --rules flag matching the syntax provided in
rules = [ "... " ] in .scalafix.conf files.ScalafixArguments withToolClasspath(java.net.URLClassLoader toolClasspath)
toolClasspath - Custom classpath for classloading and compiling external rules.
Must be a URLClassLoader (not regular ClassLoader) to support
compiling sources.ScalafixArguments withPaths(java.util.List<java.nio.file.Path> paths)
paths - Files and directories to run Scalafix on. The ability to pass in directories
is primarily supported to make it ergonomic to invoke the command-line interface.
It's recommended to only pass in files with this API. Directories are recursively
expanded for files matching the patterns *.scala and *.sbt
and files that do not match the path matchers provided in withExcludedPaths(List).ScalafixArguments withExcludedPaths(java.util.List<java.nio.file.PathMatcher> matchers)
matchers - Optional list of path matchers to exclude files when expanding directories
in withPaths(List).ScalafixArguments withWorkingDirectory(java.nio.file.Path path)
path - The working directory of where to invoke the command-line interface.
Primarily used to absolutize relative directories passed via
withPaths(List) and also to auto-detect the
location of .scalafix.conf.ScalafixArguments withConfig(java.util.Optional<java.nio.file.Path> config)
config - Optional path to a .scalafix.conf. If empty, Scalafix
will infer such a file from the working directory or fallback to the default
configuration.ScalafixArguments withMode(ScalafixMainMode mode)
mode - The mode to run via --check or --stdout or --auto-suppress-linter-errorsScalafixArguments withParsedArguments(java.util.List<java.lang.String> args) throws ScalafixException
args - Unparsed command-line arguments that are fed directly to main(Array[String])ScalafixException - In case of an error parsing the provided arguments.ScalafixArguments withPrintStream(java.io.PrintStream out)
out - The output stream to use for reporting diagnostics while running Scalafix.
Defaults to System.out.ScalafixArguments withClasspath(java.util.List<java.nio.file.Path> classpath)
classpath - Full Java classpath of the module being fixed. Required for running
semantic rewrites such as ExpliticResultTypes. Source files that
are to be fixed must be compiled with the semanticdb-scalac compiler
plugin and must have corresponding META-INF/semanticdb/../*.semanticdb
payloads. The dependency classpath must be included as well but dependency
sources do not have to be compiled with semanticdb-scalac.ScalafixArguments withSourceroot(java.nio.file.Path path)
path - The SemanticDB sources path passed via --sourceroot. Must match path
in -Xplugin:semanticdb:sourceroot:{path} if used. Defaults
to the current working directory.ScalafixArguments withMainCallback(ScalafixMainCallback callback)
callback - Handler for reported linter messages. If not provided, defaults to printing
linter messages to the Stdout.ScalafixArguments withCharset(java.nio.charset.Charset charset)
charset - Charset for reading source files from disk. Defaults to UTF-8.ScalafixArguments withScalaVersion(java.lang.String version)
version - The Scala compiler version used to compile this classpath.
For example "2.12.7".ScalafixArguments withScalacOptions(java.util.List<java.lang.String> options)
options - The Scala compiler flags used to compile this classpath.
For example List(-Ywarn-unused-import).java.util.List<ScalafixRule> availableRules()
withRules(List).
Takes into account built-in rules as well as the tool classpath provided via
withToolClasspath(URLClassLoader).java.util.List<ScalafixRule> rulesThatWillRun() throws ScalafixException
run()
Takes into account rules that are configured in .scalafix.conf.ScalafixException - In case of an error loading the configured rules.java.util.Optional<ScalafixException> validate()
withClasspath(List).ScalafixError[] run()
main function.