public class SuggestedFix extends Object implements Fix
Modifier and Type | Class and Description |
---|---|
static class |
SuggestedFix.Builder
Builds
SuggestedFix s. |
Modifier and Type | Method and Description |
---|---|
static SuggestedFix.Builder |
builder() |
static SuggestedFix |
delete(com.sun.source.tree.Tree node)
|
static SuggestedFix |
emptyFix()
Creates an empty
SuggestedFix . |
Collection<String> |
getImportsToAdd() |
Collection<String> |
getImportsToRemove() |
Set<Replacement> |
getReplacements(com.sun.tools.javac.tree.EndPosTable endPositions) |
String |
getShortDescription()
A short description which can be attached to the Fix to differentiate multiple fixes provided
to the user.
|
boolean |
isEmpty() |
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(int startPos,
int endPos,
String replaceWith)
Replace the characters from startPos, inclusive, until endPos, exclusive, with the given
string.
|
static SuggestedFix |
replace(com.sun.source.tree.Tree tree,
String replaceWith)
|
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)
|
String |
toString(com.sun.tools.javac.tree.JCTree.JCCompilationUnit compilationUnit) |
public Collection<String> getImportsToAdd()
getImportsToAdd
in interface Fix
public Collection<String> getImportsToRemove()
getImportsToRemove
in interface Fix
public String toString(com.sun.tools.javac.tree.JCTree.JCCompilationUnit compilationUnit)
public String getShortDescription()
Fix
Empty string generates the default description.
getShortDescription
in interface Fix
public Set<Replacement> getReplacements(com.sun.tools.javac.tree.EndPosTable endPositions)
getReplacements
in interface Fix
public static SuggestedFix replace(com.sun.source.tree.Tree tree, String replaceWith)
public static SuggestedFix replace(int startPos, int endPos, String replaceWith)
startPos
- The position from which to start replacing, inclusiveendPos
- The position at which to end replacing, exclusivereplaceWith
- The string to replace withpublic static SuggestedFix replace(com.sun.source.tree.Tree node, String replaceWith, int startPosAdjustment, int endPosAdjustment)
fix.replace(node, "replacement", 5, -5)
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)public static SuggestedFix prefixWith(com.sun.source.tree.Tree node, String prefix)
public static SuggestedFix postfixWith(com.sun.source.tree.Tree node, String postfix)
public static SuggestedFix delete(com.sun.source.tree.Tree node)
public static SuggestedFix swap(com.sun.source.tree.Tree node1, com.sun.source.tree.Tree node2)
public static SuggestedFix emptyFix()
SuggestedFix
.public static SuggestedFix.Builder builder()
Copyright © 2021 Google LLC. All rights reserved.