本文整理汇总了Java中org.eclipse.jdt.core.dom.DoStatement类的典型用法代码示例。如果您正苦于以下问题:Java DoStatement类的具体用法?Java DoStatement怎么用?Java DoStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoStatement类属于org.eclipse.jdt.core.dom包,在下文中一共展示了DoStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: locationNeedsParentheses
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
示例2: getStatementType
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
/**
* Method that check statement type.
* @author Mariana Azevedo
* @since 13/07/2014
* @param itStatement
*/
private void getStatementType(Object itStatement) {
if (itStatement instanceof CatchClause){
this.visitor.visit((CatchClause)itStatement);
}else if (itStatement instanceof ForStatement){
this.visitor.visit((ForStatement)itStatement);
}else if (itStatement instanceof IfStatement){
this.visitor.visit((IfStatement)itStatement);
}else if (itStatement instanceof WhileStatement){
this.visitor.visit((WhileStatement)itStatement);
}else if (itStatement instanceof TryStatement){
this.visitor.visit((TryStatement)itStatement);
}else if (itStatement instanceof ConditionalExpression){
this.visitor.visit((ConditionalExpression)itStatement);
}else if (itStatement instanceof SwitchCase){
this.visitor.visit((SwitchCase)itStatement);
}else if (itStatement instanceof DoStatement){
this.visitor.visit((DoStatement)itStatement);
}else if (itStatement instanceof ExpressionStatement){
this.visitor.visit((ExpressionStatement)itStatement);
}
}
示例3: getParentLoopBody
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private Statement getParentLoopBody(ASTNode node) {
Statement stmt = null;
ASTNode start = node;
while (start != null && !(start instanceof ForStatement) && !(start instanceof DoStatement) && !(start instanceof WhileStatement) && !(start instanceof EnhancedForStatement) && !(start instanceof SwitchStatement)) {
start = start.getParent();
}
if (start instanceof ForStatement) {
stmt = ((ForStatement) start).getBody();
} else if (start instanceof DoStatement) {
stmt = ((DoStatement) start).getBody();
} else if (start instanceof WhileStatement) {
stmt = ((WhileStatement) start).getBody();
} else if (start instanceof EnhancedForStatement) {
stmt = ((EnhancedForStatement) start).getBody();
}
if (start != null && start.getParent() instanceof LabeledStatement) {
LabeledStatement labeledStatement = (LabeledStatement) start.getParent();
fEnclosingLoopLabel = labeledStatement.getLabel();
}
return stmt;
}
示例4: visit
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
@Override
public boolean visit(DoStatement node) {
boolean result = super.visit(node);
try {
int actionStart = getTokenScanner().getTokenEndOffset(ITerminalSymbols.TokenNamedo, node.getStartPosition());
if (getSelection().getOffset() == actionStart) {
invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_after_do_keyword, JavaStatusContext.create(fCUnit, getSelection()));
return false;
}
} catch (CoreException e) {
// ignore
}
return result;
}
示例5: locationNeedsParentheses
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor
&& locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation
// ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
示例6: getParentLoopBody
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private Statement getParentLoopBody(ASTNode node) {
Statement stmt = null;
ASTNode start = node;
while (start != null
&& !(start instanceof ForStatement)
&& !(start instanceof DoStatement)
&& !(start instanceof WhileStatement)
&& !(start instanceof EnhancedForStatement)
&& !(start instanceof SwitchStatement)) {
start = start.getParent();
}
if (start instanceof ForStatement) {
stmt = ((ForStatement) start).getBody();
} else if (start instanceof DoStatement) {
stmt = ((DoStatement) start).getBody();
} else if (start instanceof WhileStatement) {
stmt = ((WhileStatement) start).getBody();
} else if (start instanceof EnhancedForStatement) {
stmt = ((EnhancedForStatement) start).getBody();
}
if (start != null && start.getParent() instanceof LabeledStatement) {
LabeledStatement labeledStatement = (LabeledStatement) start.getParent();
fEnclosingLoopLabel = labeledStatement.getLabel();
}
return stmt;
}
示例7: visit
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
@Override
public boolean visit(DoStatement node) {
boolean result = super.visit(node);
try {
int actionStart =
getTokenScanner()
.getTokenEndOffset(ITerminalSymbols.TokenNamedo, node.getStartPosition());
if (getSelection().getOffset() == actionStart) {
invalidSelection(
RefactoringCoreMessages.ExtractMethodAnalyzer_after_do_keyword,
JavaStatusContext.create(fCUnit, getSelection()));
return false;
}
} catch (CoreException e) {
// ignore
}
return result;
}
示例8: preNext
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
@Override
public boolean preNext(Statement curElement) {
switch (curElement.getNodeType()) {
case ASTNode.WHILE_STATEMENT:
exportWhile((WhileStatement) curElement);
break;
case ASTNode.FOR_STATEMENT:
exportFor((ForStatement) curElement);
break;
case ASTNode.ENHANCED_FOR_STATEMENT:
exportForEach((EnhancedForStatement) curElement);
break;
case ASTNode.DO_STATEMENT:
exportDoWhileStatement((DoStatement) curElement);
break;
}
return true;
}
示例9: getParentLoopBody
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private Statement getParentLoopBody(ASTNode node) {
Statement stmt= null;
ASTNode start= node;
while (start != null
&& !(start instanceof ForStatement)
&& !(start instanceof DoStatement)
&& !(start instanceof WhileStatement)
&& !(start instanceof EnhancedForStatement)
&& !(start instanceof SwitchStatement)) {
start= start.getParent();
}
if (start instanceof ForStatement) {
stmt= ((ForStatement)start).getBody();
} else if (start instanceof DoStatement) {
stmt= ((DoStatement)start).getBody();
} else if (start instanceof WhileStatement) {
stmt= ((WhileStatement)start).getBody();
} else if (start instanceof EnhancedForStatement) {
stmt= ((EnhancedForStatement)start).getBody();
}
if (start != null && start.getParent() instanceof LabeledStatement) {
LabeledStatement labeledStatement= (LabeledStatement)start.getParent();
fEnclosingLoopLabel= labeledStatement.getLabel();
}
return stmt;
}
示例10: visit
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
@Override
public boolean visit(DoStatement node) {
boolean result= super.visit(node);
try {
int actionStart= getTokenScanner().getTokenEndOffset(ITerminalSymbols.TokenNamedo, node.getStartPosition());
if (getSelection().getOffset() == actionStart) {
invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_after_do_keyword, JavaStatusContext.create(fCUnit, getSelection()));
return false;
}
} catch (CoreException e) {
// ignore
}
return result;
}
示例11: isLastStatementInEnclosingMethodOrLambda
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private static boolean isLastStatementInEnclosingMethodOrLambda(Statement statement) {
ASTNode currentStructure= statement;
ASTNode currentParent= statement.getParent();
while (!(currentParent instanceof MethodDeclaration || currentParent instanceof LambdaExpression)) {
// should not be in a loop
if (currentParent instanceof ForStatement || currentParent instanceof EnhancedForStatement
|| currentParent instanceof WhileStatement || currentParent instanceof DoStatement) {
return false;
}
if (currentParent instanceof Block) {
Block parentBlock= (Block) currentParent;
if (parentBlock.statements().indexOf(currentStructure) != parentBlock.statements().size() - 1) { // not last statement in the block
return false;
}
}
currentStructure= currentParent;
currentParent= currentParent.getParent();
}
return true;
}
示例12: isLoopStatement
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
private boolean isLoopStatement(Block block) {
ASTNode parent = block.getParent();
return
parent instanceof WhileStatement ||
parent instanceof ForStatement ||
parent instanceof DoStatement ||
parent instanceof EnhancedForStatement ||
parent instanceof IfStatement;
}
示例13: visit
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
/**
* @see ASTVisitor#visit(DoStatement)
*/
@Override
public boolean visit(DoStatement node) {
cyclomaticComplexityIndex++;
sumCyclomaticComplexity++;
inspectExpression(node.getExpression());
return true;
}
示例14: isControlStatementBody
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
/**
* 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;
}
示例15: endVisit
import org.eclipse.jdt.core.dom.DoStatement; //导入依赖的package包/类
@Override
public void endVisit(DoStatement node) {
if (skipNode(node)) {
return;
}
DoWhileFlowInfo info = createDoWhile();
setFlowInfo(node, info);
info.mergeAction(getFlowInfo(node.getBody()), fFlowContext);
// No need to merge the condition. It was already considered by the InputFlowAnalyzer.
info.removeLabel(null);
}