public static class LintFix.ReplaceStringBuilder
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.ReplaceStringBuilder |
all()
Replaces this entire range
|
LintFix.ReplaceStringBuilder |
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.ReplaceStringBuilder |
autoFix(boolean robot,
boolean independent)
Sets options related to auto-applying this fix.
|
LintFix.ReplaceStringBuilder |
beginning()
Inserts into the beginning of the range
|
LintFix |
build()
Constructs a
LintFix for this string replacement |
LintFix.ReplaceStringBuilder |
end()
Inserts after the end of the range
|
LintFix.ReplaceStringBuilder |
independent(boolean independent)
Whether this fix is independent of other fixes getting applied.
|
LintFix.ReplaceStringBuilder |
name(java.lang.String displayName)
Sets display name.
|
LintFix.ReplaceStringBuilder |
name(java.lang.String displayName,
java.lang.String familyName)
Sets display name and family name.
|
LintFix.ReplaceStringBuilder |
pattern(java.lang.String oldPattern)
Replaces the given pattern match (or the first group within it, if any)
|
LintFix.ReplaceStringBuilder |
range(com.android.tools.lint.detector.api.Location range)
Sets a location range to use for searching for the text or pattern.
|
LintFix.ReplaceStringBuilder |
reformat(boolean reformat)
Whether the replaced range should be reformatted
|
LintFix.ReplaceStringBuilder |
robot(boolean robot)
Sets whether this fix can be applied by a robot, e.g.
|
LintFix.ReplaceStringBuilder |
select(java.lang.String selectPattern)
Sets a pattern to select; if it contains parentheses, group(1) will be selected.
|
LintFix.ReplaceStringBuilder |
sharedName(java.lang.String familyName)
Sets the family name.
|
LintFix.ReplaceStringBuilder |
shortenNames()
The IDE should simplify fully qualified names in the element after this fix has been run
(off by default)
|
LintFix.ReplaceStringBuilder |
text(java.lang.String oldText)
Replaces the given literal text
|
LintFix.ReplaceStringBuilder |
with(java.lang.String newText)
The text to replace the old text or pattern with.
|
@Nls protected java.lang.String displayName
@Nls @Nullable protected java.lang.String familyName
public LintFix.ReplaceStringBuilder name(java.lang.String displayName)
displayName - the display namepublic LintFix.ReplaceStringBuilder 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.ReplaceStringBuilder 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.ReplaceStringBuilder pattern(java.lang.String oldPattern)
public LintFix.ReplaceStringBuilder text(java.lang.String oldText)
public LintFix.ReplaceStringBuilder range(@NonNull com.android.tools.lint.detector.api.Location range)
public LintFix.ReplaceStringBuilder all()
public LintFix.ReplaceStringBuilder beginning()
public LintFix.ReplaceStringBuilder end()
public LintFix.ReplaceStringBuilder select(@Nullable java.lang.String selectPattern)
public LintFix.ReplaceStringBuilder with(java.lang.String newText)
pattern(String)}.public LintFix.ReplaceStringBuilder shortenNames()
public LintFix.ReplaceStringBuilder reformat(boolean reformat)
public LintFix.ReplaceStringBuilder 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.ReplaceStringBuilder 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.ReplaceStringBuilder 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.ReplaceStringBuilder autoFix()
autoFix(boolean, boolean): indicates that this fix can
safely be applied in auto-fix mode, in parallel with other fixes.