public final class PaddedCellBulk
extends java.lang.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 autostyleCheck fails after calling autostyleApply, then they would
justifiably be frustrated. Luckily, every time autostyleCheck 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.
Autostyle 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 PaddedCell |
anyMisbehave(Formatter formatter,
java.util.List<java.io.File> problemFiles)
Returns true if the formatter is misbehaving for any of the given files.
|
static PaddedCell |
anyMisbehave(Formatter formatter,
java.util.List<java.io.File> problemFiles,
long timeoutMs)
Same as
anyMisbehave(Formatter, List) but with a customizable timeout. |
static void |
apply(Formatter formatter,
java.io.File file)
Performs the typical autostyleApply, but with PaddedCell handling of misbehaving FormatterSteps.
|
static boolean |
applyAnyChanged(Formatter formatter,
java.io.File file)
Performs the typical autostyleApply, but with PaddedCell handling of misbehaving FormatterSteps.
|
static java.util.List<java.io.File> |
check(java.io.File rootDir,
java.io.File diagnoseDir,
Formatter formatter,
java.util.List<java.io.File> problemFiles)
Performs a full check using PaddedCell logic on the given files with the given formatter.
|
@Nullable public static PaddedCell anyMisbehave(Formatter formatter, java.util.List<java.io.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 autostyleApply, but autostyleCheck 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 autostyleCheck, it can help you tell the user about a misbehaving rule and alert her to how to enable paddedCell mode, with minimal effort.
@Nullable public static PaddedCell anyMisbehave(Formatter formatter, java.util.List<java.io.File> problemFiles, long timeoutMs)
Same as anyMisbehave(Formatter, List) but with a customizable timeout.
public static java.util.List<java.io.File> check(java.io.File rootDir,
java.io.File diagnoseDir,
Formatter formatter,
java.util.List<java.io.File> problemFiles)
throws java.io.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.java.io.IOExceptionpublic static void apply(Formatter formatter, java.io.File file) throws java.io.IOException
Performs the typical autostyleApply, but with PaddedCell handling of misbehaving FormatterSteps.
java.io.IOExceptionpublic static boolean applyAnyChanged(Formatter formatter, java.io.File file) throws java.io.IOException
Performs the typical autostyleApply, but with PaddedCell handling of misbehaving FormatterSteps.
java.io.IOException