public interface ScalafixMainArgs
To obtain an instance of MainArgs, use Scalafix.newMainArgs().
Instances of MainArgs are immutable and thread safe. It is safe to re-use the same
MainArgs instance for multiple Scalafix invocations.
| Modifier and Type | Method and Description |
|---|---|
ScalafixMainArgs |
withArgs(java.util.List<java.lang.String> args) |
ScalafixMainArgs |
withCharset(java.nio.charset.Charset charset) |
ScalafixMainArgs |
withClasspath(java.util.List<java.nio.file.Path> classpath) |
ScalafixMainArgs |
withConfig(java.nio.file.Path path) |
ScalafixMainArgs |
withExcludedPaths(java.util.List<java.nio.file.PathMatcher> matchers) |
ScalafixMainArgs |
withMainCallback(ScalafixMainCallback callback) |
ScalafixMainArgs |
withMode(ScalafixMainMode mode) |
ScalafixMainArgs |
withPaths(java.util.List<java.nio.file.Path> paths) |
ScalafixMainArgs |
withPrintStream(java.io.PrintStream out) |
ScalafixMainArgs |
withRules(java.util.List<java.lang.String> rules) |
ScalafixMainArgs |
withSourceroot(java.nio.file.Path path) |
ScalafixMainArgs |
withToolClasspath(java.net.URLClassLoader toolClasspath) |
ScalafixMainArgs |
withWorkingDirectory(java.nio.file.Path path) |
ScalafixMainArgs 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.ScalafixMainArgs 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.ScalafixMainArgs 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).ScalafixMainArgs withExcludedPaths(java.util.List<java.nio.file.PathMatcher> matchers)
matchers - Optional list of path matchers to exclude files when expanding directories
in withPaths(List).ScalafixMainArgs 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.ScalafixMainArgs withConfig(java.nio.file.Path path)
path - Optional path to a .scalafix.conf. If not provided, Scalafix
will infer such a file from the working directory or fallback to the default
configuration.ScalafixMainArgs withMode(ScalafixMainMode mode)
mode - The mode to run via --test or --stdout or --auto-suppress-linter-errorsScalafixMainArgs withArgs(java.util.List<java.lang.String> args)
args - Unparsed command-line arguments that are fed directly to main(Array[String])ScalafixMainArgs withPrintStream(java.io.PrintStream out)
out - The output stream to use for reporting diagnostics while running Scalafix.
Defaults to System.out.ScalafixMainArgs 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.ScalafixMainArgs 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.ScalafixMainArgs withMainCallback(ScalafixMainCallback callback)
callback - Handler for reported linter messages. If not provided, defaults to printing
linter messages to the Stdout.ScalafixMainArgs withCharset(java.nio.charset.Charset charset)
charset - Charset for reading source files from disk. Defaults to UTF-8.