Class SuggestedFix
java.lang.Object
com.google.errorprone.fixes.SuggestedFix
- All Implemented Interfaces:
Fix
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SuggestedFix.Builder
builder()
static SuggestedFix
delete
(com.sun.source.tree.Tree node) static SuggestedFix
emptyFix()
Creates an emptySuggestedFix
.abstract com.google.common.collect.ImmutableSet
<String> abstract com.google.common.collect.ImmutableSet
<String> com.google.common.collect.ImmutableSet
<Replacement> getReplacements
(com.sun.tools.javac.tree.EndPosTable endPositions) abstract String
A short description which can be attached to the Fix to differentiate multiple fixes provided to the user.abstract int
hashCode()
boolean
isEmpty()
static SuggestedFix
merge
(SuggestedFix first, SuggestedFix second, SuggestedFix... more) static SuggestedFix
postfixWith
(com.sun.source.tree.Tree node, String postfix) static SuggestedFix
prefixWith
(com.sun.source.tree.Tree node, String prefix) static SuggestedFix
Replace the characters from startPos, inclusive, until endPos, exclusive, with the given string.static SuggestedFix
static SuggestedFix
replace
(com.sun.source.tree.Tree node, String replaceWith, int startPosAdjustment, int endPosAdjustment) Replace a tree node with a string, but adjust the start and end positions as well.static SuggestedFix
swap
(com.sun.source.tree.Tree node1, com.sun.source.tree.Tree node2) toString
(com.sun.tools.javac.tree.JCTree.JCCompilationUnit compilationUnit) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.errorprone.fixes.Fix
getCoalescePolicy
-
Constructor Details
-
SuggestedFix
public SuggestedFix()
-
-
Method Details
-
isEmpty
-
getImportsToAdd
- Specified by:
getImportsToAdd
in interfaceFix
-
getImportsToRemove
- Specified by:
getImportsToRemove
in interfaceFix
-
toString
-
getShortDescription
Description copied from interface:Fix
A short description which can be attached to the Fix to differentiate multiple fixes provided to the user.Empty string generates the default description.
- Specified by:
getShortDescription
in interfaceFix
-
hashCode
-
getReplacements
public com.google.common.collect.ImmutableSet<Replacement> getReplacements(com.sun.tools.javac.tree.EndPosTable endPositions) - Specified by:
getReplacements
in interfaceFix
-
replace
-
replace
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
public static SuggestedFix replace(com.sun.source.tree.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
-
emptyFix
Creates an emptySuggestedFix
. -
merge
-
builder
-
toBuilder
-