class Util
extends java.lang.Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static org.eclipse.jdt.core.dom.Block |
ensureBlock(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.StructuralPropertyDescriptor property)
Tries to get a block from the given node with the given property.
|
static <T> T |
getChild(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.StructuralPropertyDescriptor property)
Gets a child from the given ASTNode, with the given rewrite being applied.
|
static <T> java.util.List<T> |
getChildList(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.ChildListPropertyDescriptor property)
Gets a child list from the given ASTNode, with the given rewrite being applied.
|
static org.eclipse.jdt.core.dom.Statement |
printlnSystemOut(org.eclipse.jdt.core.dom.AST ast,
org.eclipse.jdt.core.dom.Expression output)
Returns a new statement which prints the result of the given expression on System.out.
|
static org.eclipse.jdt.core.dom.Statement |
printlnSystemOut(org.eclipse.jdt.core.dom.AST ast,
java.lang.String output)
Returns a new statement which prints the given string output on System.out.
|
public static <T> T getChild(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.StructuralPropertyDescriptor property)
ASTRewrite.get(ASTNode, StructuralPropertyDescriptor), however casts the result
to the desired type directly.
For lists, use the Util#getChildList(ASTNode, ASTRewrite, StructuralPropertyDescriptor method instead.T - The type of the child to get. Note that the cast is not checked, therefore the client must be sure that the type is correct.node - The node to get a child from.rewrite - The ASTRewrite instance which keeps track of rewritten AST elements.property - The property to get.public static <T> java.util.List<T> getChildList(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.ChildListPropertyDescriptor property)
getChild(ASTNode, ASTRewrite, StructuralPropertyDescriptor) method instead.T - The type of the list elements to get. Note that the cast is not checked, therefore the client must be sure that the type is correct.node - The node to get a child from.rewrite - The ASTRewrite instance which keeps track of rewritten AST elements.property - The property to get.public static org.eclipse.jdt.core.dom.Statement printlnSystemOut(org.eclipse.jdt.core.dom.AST ast,
java.lang.String output)
printlnSystemOut(AST, Expression)
to print anything which is not a String literal.ast - The AST instance to use when creating new ASTNode instances with the factory AST.newCHILD methods.output - The output to print with System.out.public static org.eclipse.jdt.core.dom.Statement printlnSystemOut(org.eclipse.jdt.core.dom.AST ast,
org.eclipse.jdt.core.dom.Expression output)
printlnSystemOut(AST, String) to directly
print a string literal.ast - The AST instance to use when creating new ASTNode instances with the factory AST.newCHILD methods.output - The output to print with System.out.public static org.eclipse.jdt.core.dom.Block ensureBlock(org.eclipse.jdt.core.dom.ASTNode node,
org.eclipse.jdt.core.dom.rewrite.ASTRewrite rewrite,
org.eclipse.jdt.core.dom.StructuralPropertyDescriptor property)
if (x) {
y;
...
} -> left as is
if (x) y; -> converted to the above representationA non-existing statement (e.g. a missing else-block) is converted to an empty block without any statements.
node - The node which contains the given property, which can be a block or a single statement.rewrite - The rewrite to use. If a block is created, the rewrite is used to set the new block.property - The property containing the block/statement.