public final class PaddedCellBulk extends Object
Incorporates the PaddedCell machinery into broader apply / check usage.
Here’s the general workflow:
Initially, paddedCell is off. That’s the default, and there’s no need for users to know about it.
If they encounter a scenario where spotlessCheck fails after calling spotlessApply, then they would justifiably be frustrated. Luckily, every time spotlessCheck fails, it passes the failed files to anyMisbehave(Formatter, List), which checks to see if any of the rules are causing a cycle or some other kind of mischief. If they are, it can give the user a special error message instructing them to turn on paddedCell.
Spotless check behaves as normal, finding a list of problem files, but then passes that list to check(File, File, Formatter, List). If there were no problem files, then paddedCell is no longer necessary, so users might as well turn it off, so we give that info as a warning.
| Constructor and Description |
|---|
PaddedCellBulk() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
anyMisbehave(Formatter formatter,
List<File> problemFiles)
Returns true if the formatter is misbehaving for any of the given files.
|
static boolean |
anyMisbehave(Formatter formatter,
List<File> problemFiles,
long timeoutMs)
Same as
anyMisbehave(Formatter, List) but with a customizable timeout. |
static void |
apply(Formatter formatter,
File file)
Performs the typical spotlessApply, but with PaddedCell handling of misbehaving FormatterSteps.
|
static boolean |
applyAnyChanged(Formatter formatter,
File file)
Performs the typical spotlessApply, but with PaddedCell handling of misbehaving FormatterSteps.
|
static List<File> |
check(File rootDir,
File diagnoseDir,
Formatter formatter,
List<File> problemFiles)
Performs a full check using PaddedCell logic on the given files with the given formatter.
|
public static boolean anyMisbehave(Formatter formatter, List<File> problemFiles)
Returns true if the formatter is misbehaving for any of the given files.
If, after 500ms of searching, none are found that misbehave, it gives the formatter the benefit of the doubt and returns false. The real point of this check is to handle the case that a user just called spotlessApply, but spotlessCheck is still failing. In that case, all of the problemFiles are guaranteed to be misbehaving, so this time limit doesn’t hurt correctness.
If you call this method after every failed spotlessCheck, it can help you tell the user about a misbehaving rule and alert her to how to enable paddedCell mode, with minimal effort.
public static boolean anyMisbehave(Formatter formatter, List<File> problemFiles, long timeoutMs)
Same as anyMisbehave(Formatter, List) but with a customizable timeout.
public static List<File> check(File rootDir, File diagnoseDir, Formatter formatter, List<File> problemFiles) throws IOException
Performs a full check using PaddedCell logic on the given files with the given formatter. If any are found which do not conform to the PaddedCell, a description of the error will be written to the diagnose dir.
rootDir - The root directory, used to determine the relative paths of the problemFiles.diagnoseDir - Directory where problems are described (based on the relative paths determined based on rootDir).formatter - The formatter to apply.problemFiles - The files with which we have a problem.IOExceptionpublic static void apply(Formatter formatter, File file) throws IOException
Performs the typical spotlessApply, but with PaddedCell handling of misbehaving FormatterSteps.
IOExceptionpublic static boolean applyAnyChanged(Formatter formatter, File file) throws IOException
Performs the typical spotlessApply, but with PaddedCell handling of misbehaving FormatterSteps.
IOException