本文整理汇总了Java中org.eclipse.jdt.core.dom.EnhancedForStatement.BODY_PROPERTY属性的典型用法代码示例。如果您正苦于以下问题:Java EnhancedForStatement.BODY_PROPERTY属性的具体用法?Java EnhancedForStatement.BODY_PROPERTY怎么用?Java EnhancedForStatement.BODY_PROPERTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.dom.EnhancedForStatement
的用法示例。
在下文中一共展示了EnhancedForStatement.BODY_PROPERTY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isControlStatementBody
/**
* Returns true if a node at a given location is a body of a control statement. Such body nodes are
* interesting as when replacing them, it has to be evaluates if a Block is needed instead.
* E.g. <code> if (x) do(); -> if (x) { do1(); do2() } </code>
*
* @param locationInParent Location of the body node
* @return Returns true if the location is a body node location of a control statement.
*/
public static boolean isControlStatementBody(StructuralPropertyDescriptor locationInParent) {
return locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
|| locationInParent == ForStatement.BODY_PROPERTY
|| locationInParent == EnhancedForStatement.BODY_PROPERTY
|| locationInParent == WhileStatement.BODY_PROPERTY
|| locationInParent == DoStatement.BODY_PROPERTY;
}
示例2: isDangligIf
public boolean isDangligIf() {
List<Statement> statements = fDeclaration.getBody().statements();
if (statements.size() != 1) return false;
ASTNode p = statements.get(0);
while (true) {
if (p instanceof IfStatement) {
return ((IfStatement) p).getElseStatement() == null;
} else {
ChildPropertyDescriptor childD;
if (p instanceof WhileStatement) {
childD = WhileStatement.BODY_PROPERTY;
} else if (p instanceof ForStatement) {
childD = ForStatement.BODY_PROPERTY;
} else if (p instanceof EnhancedForStatement) {
childD = EnhancedForStatement.BODY_PROPERTY;
} else if (p instanceof DoStatement) {
childD = DoStatement.BODY_PROPERTY;
} else if (p instanceof LabeledStatement) {
childD = LabeledStatement.BODY_PROPERTY;
} else {
return false;
}
Statement body = (Statement) p.getStructuralProperty(childD);
if (body instanceof Block) {
return false;
} else {
p = body;
}
}
}
}
示例3: insertAt
private void insertAt(ASTNode target, Statement declaration) {
ASTRewrite rewrite = fCURewrite.getASTRewrite();
TextEditGroup groupDescription =
fCURewrite.createGroupDescription(
RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable);
ASTNode parent = target.getParent();
StructuralPropertyDescriptor locationInParent = target.getLocationInParent();
while (locationInParent != Block.STATEMENTS_PROPERTY
&& locationInParent != SwitchStatement.STATEMENTS_PROPERTY) {
if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
|| locationInParent == ForStatement.BODY_PROPERTY
|| locationInParent == EnhancedForStatement.BODY_PROPERTY
|| locationInParent == DoStatement.BODY_PROPERTY
|| locationInParent == WhileStatement.BODY_PROPERTY) {
// create intermediate block if target was the body property of a control statement:
Block replacement = rewrite.getAST().newBlock();
ListRewrite replacementRewrite =
rewrite.getListRewrite(replacement, Block.STATEMENTS_PROPERTY);
replacementRewrite.insertFirst(declaration, null);
replacementRewrite.insertLast(rewrite.createMoveTarget(target), null);
rewrite.replace(target, replacement, groupDescription);
return;
}
target = parent;
parent = parent.getParent();
locationInParent = target.getLocationInParent();
}
ListRewrite listRewrite =
rewrite.getListRewrite(parent, (ChildListPropertyDescriptor) locationInParent);
listRewrite.insertBefore(declaration, target, groupDescription);
}
示例4: isDangligIf
public boolean isDangligIf() {
List<Statement> statements= fDeclaration.getBody().statements();
if (statements.size() != 1)
return false;
ASTNode p= statements.get(0);
while (true) {
if (p instanceof IfStatement) {
return ((IfStatement) p).getElseStatement() == null;
} else {
ChildPropertyDescriptor childD;
if (p instanceof WhileStatement) {
childD= WhileStatement.BODY_PROPERTY;
} else if (p instanceof ForStatement) {
childD= ForStatement.BODY_PROPERTY;
} else if (p instanceof EnhancedForStatement) {
childD= EnhancedForStatement.BODY_PROPERTY;
} else if (p instanceof DoStatement) {
childD= DoStatement.BODY_PROPERTY;
} else if (p instanceof LabeledStatement) {
childD= LabeledStatement.BODY_PROPERTY;
} else {
return false;
}
Statement body= (Statement) p.getStructuralProperty(childD);
if (body instanceof Block) {
return false;
} else {
p= body;
}
}
}
}
示例5: insertAt
private void insertAt(ASTNode target, Statement declaration) {
ASTRewrite rewrite= fCURewrite.getASTRewrite();
TextEditGroup groupDescription= fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable);
ASTNode parent= target.getParent();
StructuralPropertyDescriptor locationInParent= target.getLocationInParent();
while (locationInParent != Block.STATEMENTS_PROPERTY && locationInParent != SwitchStatement.STATEMENTS_PROPERTY) {
if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
|| locationInParent == ForStatement.BODY_PROPERTY
|| locationInParent == EnhancedForStatement.BODY_PROPERTY
|| locationInParent == DoStatement.BODY_PROPERTY
|| locationInParent == WhileStatement.BODY_PROPERTY) {
// create intermediate block if target was the body property of a control statement:
Block replacement= rewrite.getAST().newBlock();
ListRewrite replacementRewrite= rewrite.getListRewrite(replacement, Block.STATEMENTS_PROPERTY);
replacementRewrite.insertFirst(declaration, null);
replacementRewrite.insertLast(rewrite.createMoveTarget(target), null);
rewrite.replace(target, replacement, groupDescription);
return;
}
target= parent;
parent= parent.getParent();
locationInParent= target.getLocationInParent();
}
ListRewrite listRewrite= rewrite.getListRewrite(parent, (ChildListPropertyDescriptor)locationInParent);
listRewrite.insertBefore(declaration, target, groupDescription);
}
示例6: isControlStatementBody
/**
* Returns true if a node at a given location is a body of a control statement. Such body nodes are
* interesting as when replacing them, it has to be evaluates if a Block is needed instead.
* E.g. <code> if (x) do(); -> if (x) { do1(); do2() } </code>
*
* @param locationInParent Location of the body node
* @return Returns true if the location is a body node location of a control statement.
*/
public static boolean isControlStatementBody(StructuralPropertyDescriptor locationInParent) {
return locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
|| locationInParent == ForStatement.BODY_PROPERTY
|| locationInParent == EnhancedForStatement.BODY_PROPERTY
|| locationInParent == WhileStatement.BODY_PROPERTY
|| locationInParent == DoStatement.BODY_PROPERTY;
}