public class FormatExtension extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
name |
protected SpotlessExtension |
root |
protected List<FormatterStep> |
steps
The steps that need to be added.
|
protected FileCollection |
target
The files that need to be formatted.
|
Constructor and Description |
---|
FormatExtension(String name,
SpotlessExtension root) |
Modifier and Type | Method and Description |
---|---|
void |
custom(String name,
groovy.lang.Closure<String> formatter)
Adds a custom step.
|
void |
custom(String name,
Throwing.Function<String,String> formatter)
Adds a custom step.
|
void |
customLazy(String name,
Throwing.Supplier<Throwing.Function<String,String>> formatterSupplier)
Adds the given custom step, which is constructed lazily for performance reasons.
|
void |
customLazyGroovy(String name,
Throwing.Supplier<groovy.lang.Closure<String>> formatterSupplier)
Same as
customLazy(String, com.diffplug.common.base.Throwing.Supplier) , but for Groovy closures. |
void |
customReplace(String name,
CharSequence original,
CharSequence after)
Highly efficient find-replace char sequence.
|
void |
customReplaceRegex(String name,
String regex,
String replacement)
Highly efficient find-replace regex.
|
void |
endWithNewline()
Ensures that files end with a single newline.
|
protected Project |
getProject()
Returns the project that this extension is attached to.
|
void |
indentWithSpaces()
Ensures that the files are indented using spaces.
|
void |
indentWithSpaces(int tabToSpaces)
Ensures that the files are indented using spaces.
|
void |
indentWithTabs()
Ensures that the files are indented using tabs.
|
void |
indentWithTabs(int tabToSpaces)
Ensures that the files are indented using tabs.
|
void |
licenseHeader(String licenseHeader,
String delimiter) |
void |
licenseHeaderFile(Object licenseHeaderFile,
String delimiter) |
protected FileCollection |
parseTarget(Object target) |
protected void |
setupTask(FormatTask task)
Sets up a FormatTask according to the values in this extension.
|
void |
target(Object... targets)
FileCollections pass through raw.
|
void |
trimTrailingWhitespace()
Removes trailing whitespace.
|
protected final String name
protected final SpotlessExtension root
protected FileCollection target
protected List<FormatterStep> steps
public FormatExtension(String name, SpotlessExtension root)
public void target(Object... targets)
protected FileCollection parseTarget(Object target)
public void customLazy(String name, Throwing.Supplier<Throwing.Function<String,String>> formatterSupplier)
customLazyGroovy(String, com.diffplug.common.base.Throwing.Supplier)
.public void customLazyGroovy(String name, Throwing.Supplier<groovy.lang.Closure<String>> formatterSupplier)
customLazy(String, com.diffplug.common.base.Throwing.Supplier)
, but for Groovy closures.public void custom(String name, groovy.lang.Closure<String> formatter)
public void custom(String name, Throwing.Function<String,String> formatter)
public void customReplace(String name, CharSequence original, CharSequence after)
public void customReplaceRegex(String name, String regex, String replacement)
public void trimTrailingWhitespace()
public void endWithNewline()
public void indentWithSpaces(int tabToSpaces)
public void indentWithSpaces()
public void indentWithTabs(int tabToSpaces)
public void indentWithTabs()
public void licenseHeader(String licenseHeader, String delimiter)
licenseHeader
- Content that should be at the top of every filedelimiter
- Spotless will look for a line that starts with this to know what the "top" is.public void licenseHeaderFile(Object licenseHeaderFile, String delimiter)
licenseHeaderFile
- Content that should be at the top of every filedelimiter
- Spotless will look for a line that starts with this to know what the "top" is.protected void setupTask(FormatTask task) throws Exception
Exception
protected Project getProject()