public class LintFix
extends java.lang.Object
The set of operations is quite limited at the moment; more will be added over time.
| Modifier and Type | Class and Description |
|---|---|
static class |
LintFix.Builder
Builder for creating various types of fixes
|
static class |
LintFix.DataMap
General map storage for quickfix data; clients can look up via map keys or types of values
|
static class |
LintFix.FixMapBuilder |
static class |
LintFix.GroupBuilder
Builder for constructing a group of fixes
|
static class |
LintFix.GroupType
Captures the various types of a
LintFix.LintFixGroup |
static class |
LintFix.LintFixGroup
A list of quickfixes
|
static class |
LintFix.ReplaceString
Convenience class for the common scenario of suggesting a fix which involves replacing a
static string or regular expression with a replacement string
|
static class |
LintFix.ReplaceStringBuilder
A builder for replacing strings
|
static class |
LintFix.SetAttribute
Convenience class for the common scenario of suggesting a fix which involves setting an XML
attribute.
|
static class |
LintFix.SetAttributeBuilder |
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
displayName |
protected java.lang.String |
familyName |
boolean |
independent
Whether this fix is independent of other fixes getting applied.
|
boolean |
robot
Whether this fix can be applied by a robot, e.g.
|
| Modifier | Constructor and Description |
|---|---|
protected |
LintFix(java.lang.String displayName) |
protected |
LintFix(java.lang.String displayName,
java.lang.String familyName) |
| Modifier and Type | Method and Description |
|---|---|
LintFix |
autoFix()
Convenience method for
autoFix(boolean, boolean): indicates that this fix can safely
be applied in auto-fix mode, in parallel with other fixes. |
LintFix |
autoFix(boolean robot,
boolean independent) |
static LintFix.Builder |
create()
Creates a new Quickfix Builder
|
static <T> T |
getData(LintFix fix,
java.lang.Class<T> key)
Convenience wrapper which checks whether the given fix is a map, and if so returns the value
stored by its key
|
java.lang.String |
getDisplayName()
Return display name
|
java.lang.String |
getFamilyName()
Returns the "family" name; the shared name to use to apply *all* fixes of the same family
name in a single go.
|
@Nls @Nullable protected final java.lang.String displayName
@Nls @Nullable protected final java.lang.String familyName
public boolean robot
Examples of fixes which are not auto-fixable:
(1) A fix which introduces a semantic change that may not be desirable. For example, lint may warn that the use of an API is discouraged and offer a similar but not identical replacement; in this case the developer needs to consider the implications of the suggestion.
(2) A fix for a problem where just a part of the solution is offered as a fix, and there are many other plausible paths a developer might take, such as lint telling you that you have too many actions in the toolbar, and a fix is offered to move each action into a menu.
public boolean independent
Lint can automatically apply all fixes which are independent in a single pass. An example of an independent fix is removal of an unused import; removing one unused import does not invalidate a warning (and fix) for another unused import. (Of course, it's possible that another fix will introduce a new dependency on the formerly unused class, but this is rare.)
However, if we have a duplicate declaration warning, we might put a fix on each one of the duplicates to delete them; if we apply one, we wouldn't want to apply the other. In fix mode, lint will only apply the first fix in a compilation unit that is not independent; it will then need to re-analyze the compilation unit a second time, and if there are additional fixes found, apply just the first such dependent fix, and so on. This means that for N fixes that are not independent, it will reanalyze the file N times, which is obviously slower.
protected LintFix(@Nullable
java.lang.String displayName)
protected LintFix(@Nullable
java.lang.String displayName,
@Nullable
java.lang.String familyName)
@NonNull public static LintFix.Builder create()
@Nls @Nullable public java.lang.String getDisplayName()
@Nullable public java.lang.String getFamilyName()
@Nullable
public static <T> T getData(@Nullable
LintFix fix,
@NonNull
java.lang.Class<T> key)
public LintFix autoFix(boolean robot, boolean independent)
public LintFix autoFix()
autoFix(boolean, boolean): indicates that this fix can safely
be applied in auto-fix mode, in parallel with other fixes.