public abstract class ASTRewriteRule
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ASTRewriteRule.RewriteArguments
The rewrite arguments as passed to
rewrite(ASTNode, ASTRewrite, RewriteArguments) . |
static class |
ASTRewriteRule.RewritePossibilities
Denotes a set of possible rewrites, where different versions can produce different results.
|
Constructor and Description |
---|
ASTRewriteRule() |
Modifier and Type | Method and Description |
---|---|
protected ASTRewriteRule.RewritePossibilities |
createRewritePossibilities(int numberOfVersions,
org.eclipse.jdt.core.dom.ASTNode node)
Utility method to produce a rewrite possibility for the given number of versions and node.
|
protected ASTRewriteRule.RewritePossibilities |
createRewritePossibilities(int numberOfVersions,
int order,
org.eclipse.jdt.core.dom.ASTNode node)
Utility method to produce a rewrite possibility for the given number of versions and node.
|
abstract java.lang.String |
describeRule()
Returns a human-readable description of what this rule does.
|
abstract java.util.Collection<ASTRewriteRule.RewritePossibilities> |
getRewritePossibilities(org.eclipse.jdt.core.dom.ASTNode node)
Return the collection of rewrite possibilities for the given node.
|
void |
preProcess(org.eclipse.jdt.core.dom.ASTNode root)
Pre-processes the given AST node.
|
abstract void |
rewrite(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
ASTRewriteRule.RewriteArguments args)
Produce a rewrite according to the given
ASTRewriteRule.RewriteArguments . |
public void preProcess(org.eclipse.jdt.core.dom.ASTNode root)
root
- The node to pre-process.public abstract java.util.Collection<ASTRewriteRule.RewritePossibilities> getRewritePossibilities(org.eclipse.jdt.core.dom.ASTNode node)
node
- The node for which to get the collection of rewrite possibilities.public abstract void rewrite(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite, ASTRewriteRule.RewriteArguments args)
ASTRewriteRule.RewriteArguments
. This rule must be the same as ASTRewriteRule.RewritePossibilities.getSource()
for the
given arguments' rewrite possibilites instance. Otherwise, the behavior is not determined. This method may not produce any rewrite, if the
ASTRewriteRule.RewriteArguments.getVersion()
is 0. In other cases, it will produce some rewrite.node
- The node for which to produce the rewrite.rewrite
- The ASTRewrite instance to use for rewriting the node.args
- The rewrite arguments. This rule must match the source of the arguments.public abstract java.lang.String describeRule()
Language
instance.protected final ASTRewriteRule.RewritePossibilities createRewritePossibilities(int numberOfVersions, org.eclipse.jdt.core.dom.ASTNode node)
ASTRewriteRule.RewritePossibilities.getSource()
to be this rule, and ASTRewriteRule.RewritePossibilities.getOrder()
to be 0.numberOfVersions
- The possible number of rewrites produced. Must be greater than zero.node
- The node for which this rewrite possibility should be created.java.lang.IllegalArgumentException
- If the numberOfVersions is not greater than zero.protected ASTRewriteRule.RewritePossibilities createRewritePossibilities(int numberOfVersions, int order, org.eclipse.jdt.core.dom.ASTNode node)
ASTRewriteRule.RewritePossibilities.getSource()
to be this rule. Clients may override this method to produce their own implementation of rewrite possibilities.numberOfVersions
- The possible number of rewrites produced. Must be greater than zero.order
- The order to give to the given rewrite possibilities instance.node
- The node for which this rewrite possibility should be created.java.lang.IllegalArgumentException
- If the numberOfVersions is not greater than zero.