public static class LintFix.SetAttributeBuilder
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
displayName |
protected java.lang.String |
familyName |
| Modifier and Type | Method and Description |
|---|---|
LintFix.SetAttributeBuilder |
android()
Sets the namespace to the Android namespace (shortcut for
namespace(String)
passing in SdkConstants.ANDROID_URI |
LintFix.SetAttributeBuilder |
attribute(java.lang.String attribute)
Sets the attribute name.
|
LintFix.SetAttributeBuilder |
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.SetAttributeBuilder |
autoFix(boolean robot,
boolean independent)
Sets options related to auto-applying this fix.
|
LintFix |
build()
Constructs a
LintFix for this attribute operation |
LintFix.SetAttributeBuilder |
caret(int valueStartDelta)
Moves the caret to the given offset (relative to the position of the value text; can be
negative (
means not set |
LintFix.SetAttributeBuilder |
caretBegin()
Moves the caret to the beginning of the value after applying the new attribute
|
LintFix.SetAttributeBuilder |
caretEnd()
Moves the caret to the end of the value after applying the new attribute
|
LintFix.SetAttributeBuilder |
independent(boolean independent)
Whether this fix is independent of other fixes getting applied.
|
LintFix.SetAttributeBuilder |
name(java.lang.String displayName)
Sets display name.
|
LintFix.SetAttributeBuilder |
name(java.lang.String displayName,
java.lang.String familyName)
Sets display name and family name.
|
LintFix.SetAttributeBuilder |
namespace(java.lang.String namespace)
Sets the namespace to the given namespace
|
LintFix.SetAttributeBuilder |
range(com.android.tools.lint.detector.api.Location range)
Sets a location range to use for searching for the element.
|
LintFix.SetAttributeBuilder |
remove(java.lang.String attribute)
Removes the given attribute
|
LintFix.SetAttributeBuilder |
robot(boolean robot)
Sets whether this fix can be applied by a robot, e.g.
|
LintFix.SetAttributeBuilder |
select(int start,
int end)
Selects the value in the offset range (relative to value start
|
LintFix.SetAttributeBuilder |
selectAll()
Selects the newly inserted value
|
LintFix.SetAttributeBuilder |
sharedName(java.lang.String familyName)
Sets the family name.
|
LintFix.SetAttributeBuilder |
todo(java.lang.String namespace,
java.lang.String attribute)
Sets the value to TODO meant for values that aren't optional.
|
LintFix.SetAttributeBuilder |
todo(java.lang.String namespace,
java.lang.String attribute,
java.lang.String prefix,
java.lang.String suffix)
Sets the value to TODO meant for values that aren't optional.
|
LintFix.SetAttributeBuilder |
value(java.lang.String value)
Sets the value to the given value.
|
@Nls protected java.lang.String displayName
@Nls @Nullable protected java.lang.String familyName
public LintFix.SetAttributeBuilder name(java.lang.String displayName)
displayName - the display namepublic LintFix.SetAttributeBuilder name(@NonNull java.lang.String displayName, @NonNull java.lang.String familyName)
displayName - the displayNamefamilyName - the "family" name; the shared name to use to apply *all* fixes of the
same family name in a single go.public LintFix.SetAttributeBuilder sharedName(@NonNull java.lang.String familyName)
familyName - the "family" name; the shared name to use to apply *all* fixes of the
same family name in a single go.public LintFix.SetAttributeBuilder android()
namespace(String)
passing in SdkConstants.ANDROID_URIpublic LintFix.SetAttributeBuilder namespace(@Nullable java.lang.String namespace)
public LintFix.SetAttributeBuilder value(@Nullable java.lang.String value)
remove(String)public LintFix.SetAttributeBuilder attribute(@NonNull java.lang.String attribute)
public LintFix.SetAttributeBuilder remove(@NonNull java.lang.String attribute)
public LintFix.SetAttributeBuilder selectAll()
public LintFix.SetAttributeBuilder todo(@Nullable java.lang.String namespace, @NonNull java.lang.String attribute, @Nullable java.lang.String prefix, @Nullable java.lang.String suffix)
prefix - optional prefix to add before the TODO markersuffix - optional suffix to add after the TODO markerpublic LintFix.SetAttributeBuilder range(@NonNull com.android.tools.lint.detector.api.Location range)
public LintFix.SetAttributeBuilder todo(@Nullable java.lang.String namespace, @NonNull java.lang.String attribute)
public LintFix.SetAttributeBuilder select(int start, int end)
public LintFix.SetAttributeBuilder caret(int valueStartDelta)
means not setpublic LintFix.SetAttributeBuilder caretBegin()
public LintFix.SetAttributeBuilder caretEnd()
public LintFix.SetAttributeBuilder robot(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.
robot - whether this fix can be applied by a robot, e.g. does not require human
interventionpublic LintFix.SetAttributeBuilder independent(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.
independent - whether it is not the case that applying other fixes
simultaneously can invalidate this fixpublic LintFix.SetAttributeBuilder autoFix(boolean robot, boolean independent)
robot(boolean) and independent(boolean)robot - whether this fix can be applied by a robot, e.g. does not require human
interventionindependent - whether it is not the case that applying other fixes
simultaneously can invalidate this fixpublic LintFix.SetAttributeBuilder autoFix()
autoFix(boolean, boolean): indicates that this fix can
safely be applied in auto-fix mode, in parallel with other fixes.