Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- isEmpty()
- build()
- setShortDescription(String)
- setCoalescePolicy(Replacements.CoalescePolicy)
- replace(Tree, String)
- replace(int, int, String)
- replace(Tree, String, int, int)
- prefixWith(Tree, String)
- postfixWith(Tree, String)
- delete(Tree)
- swap(Tree, Tree, VisitorState)
- addImport(String)
- addStaticImport(String)
- removeImport(String)
- removeStaticImport(String)
- merge(SuggestedFix.Builder)
- merge(SuggestedFix)
Class SuggestedFix.Builder
java.lang.Object
com.google.errorprone.fixes.SuggestedFix.Builder
- Enclosing class:
SuggestedFix
Builds
SuggestedFix
s.- Author:
- alexeagle@google.com (Alex Eagle)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an import statement as part of this SuggestedFix.addStaticImport
(String importString) Add a static import statement as part of this SuggestedFix.build()
boolean
isEmpty()
merge
(@Nullable SuggestedFix other) Merges all edits fromother
intothis
.merge
(@Nullable SuggestedFix.Builder other) Merges all edits fromother
intothis
.postfixWith
(Tree node, String postfix) prefixWith
(Tree node, String prefix) removeImport
(String importString) Remove an import statement as part of this SuggestedFix.removeStaticImport
(String importString) Remove a static import statement as part of this SuggestedFix.Replace the characters from startPos, inclusive, until endPos, exclusive, with the given string.Replace a tree node with a string, but adjust the start and end positions as well.setCoalescePolicy
(Replacements.CoalescePolicy coalescePolicy) setShortDescription
(String shortDescription) Sets a custom short description for this fix.swap
(Tree node1, Tree node2, VisitorState state)
-
Constructor Details
-
Method Details
-
isEmpty
public boolean isEmpty() -
build
-
setShortDescription
Sets a custom short description for this fix. This is useful for differentiating multiple fixes from the same finding.Should be limited to one sentence.
-
setCoalescePolicy
@CanIgnoreReturnValue public SuggestedFix.Builder setCoalescePolicy(Replacements.CoalescePolicy coalescePolicy) -
replace
-
replace
@CanIgnoreReturnValue public SuggestedFix.Builder replace(int startPos, int endPos, String replaceWith) Replace the characters from startPos, inclusive, until endPos, exclusive, with the given string.- Parameters:
startPos
- The position from which to start replacing, inclusiveendPos
- The position at which to end replacing, exclusivereplaceWith
- The string to replace with
-
replace
@CanIgnoreReturnValue public SuggestedFix.Builder replace(Tree node, String replaceWith, int startPosAdjustment, int endPosAdjustment) Replace a tree node with a string, but adjust the start and end positions as well. For example, if the tree node begins at index 10 and ends at index 30, this call will replace the characters at index 15 through 25 with "replacement":fix.replace(node, "replacement", 5, -5)
- Parameters:
node
- The tree node to replacereplaceWith
- The string to replace withstartPosAdjustment
- The adjustment to add to the start position (negative is OK)endPosAdjustment
- The adjustment to add to the end position (negative is OK)
-
prefixWith
-
postfixWith
-
delete
-
swap
-
addImport
Add an import statement as part of this SuggestedFix. Import string should be of the form "foo.bar.SomeClass". -
addStaticImport
Add a static import statement as part of this SuggestedFix. Import string should be of the form "foo.bar.SomeClass.someMethod" or "foo.bar.SomeClass.SOME_FIELD". -
removeImport
Remove an import statement as part of this SuggestedFix. Import string should be of the form "foo.bar.SomeClass". -
removeStaticImport
Remove a static import statement as part of this SuggestedFix. Import string should be of the form "foo.bar.SomeClass.someMethod" or "foo.bar.SomeClass.SOME_FIELD". -
merge
Merges all edits fromother
intothis
. Ifother
is null, do nothing. -
merge
Merges all edits fromother
intothis
. Ifother
is null, do nothing.
-