Constructor and Description |
---|
JavaFixUtilities() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isPrimary(Tree tree)
Checks whether
tree can be used in places where a Primary is
required (for instance, as the receiver expression of a method invocation). |
static Fix |
removeFromParent(HintContext ctx,
String displayName,
TreePath what)
Creates a fix that removes the given code corresponding to the given tree
node from the source code.
|
static boolean |
requiresParenthesis(Tree inner,
Tree original,
Tree outter)
Checks whether putting
inner tree into outter tree,
when original is being replaced with inner requires parentheses. |
static Fix |
rewriteFix(HintContext ctx,
String displayName,
TreePath what,
String to)
Prepare a fix that will replace the given tree node (
what ) with the
given code. |
static Fix |
safelyRemoveFromParent(HintContext ctx,
String displayName,
TreePath what)
Creates a fix that removes the given code corresponding to the given tree
node together with all its usages from the source code
|
public static Fix rewriteFix(HintContext ctx, String displayName, TreePath what, String to)
what
) with the
given code. Any variables in the to
pattern will be replaced with their
values from HintContext.getVariables()
, HintContext.getMultiVariables()
and HintContext.getVariableNames()
.ctx
- basic context for which the fix should be createddisplayName
- the display name of the fixwhat
- the tree node that should be replacedto
- the new code that should replaced the what
tree nodepublic static Fix removeFromParent(HintContext ctx, String displayName, TreePath what)
ctx
- basic context for which the fix should be createddisplayName
- the display name of the fixwhat
- the tree node that should be removedpublic static Fix safelyRemoveFromParent(HintContext ctx, String displayName, TreePath what)
ctx
- basic context for which the fix should be createddisplayName
- the display name of the fixwhat
- the tree node that should be removedpublic static boolean isPrimary(@NonNull Tree tree)
tree
can be used in places where a Primary is
required (for instance, as the receiver expression of a method invocation).
This is a friend API intended to be used by the java.hints module. Other modules should not use this API because it might not be stabilized.
tree
- the tree to checktrue
iff tree
can be used where a Primary is
required.public static boolean requiresParenthesis(Tree inner, Tree original, Tree outter)
inner
tree into outter
tree,
when original
is being replaced with inner
requires parentheses.inner
- the new tree node that will be placed under outter
original
- the tree node that is being replaced with inner
outter
- the future parent node of inner
TreeMaker.Parenthesized(com.sun.source.tree.ExpressionTree)
to keep the original meaning.