use of org.jetbrains.plugins.groovy.lang.psi.controlFlow.AfterCallInstruction in project intellij-community by JetBrains.
the class ControlFlowUtils method visitAllExitPointsInner.
private static boolean visitAllExitPointsInner(Instruction last, Instruction first, boolean[] visited, ExitPointVisitor visitor) {
if (first == last)
return true;
if (last instanceof AfterCallInstruction) {
visited[last.num()] = true;
return visitAllExitPointsInner(((AfterCallInstruction) last).myCall, first, visited, visitor);
}
if (last instanceof MaybeReturnInstruction) {
return visitor.visitExitPoint(last, (GrExpression) last.getElement());
} else if (last instanceof IfEndInstruction) {
visited[last.num()] = true;
for (Instruction instruction : last.allPredecessors()) {
if (!visitAllExitPointsInner(instruction, first, visited, visitor))
return false;
}
return true;
} else if (last instanceof ThrowingInstruction) {
PsiElement element = last.getElement();
if (!(element instanceof GrThrowStatement || element instanceof GrAssertStatement))
return true;
}
PsiElement element = last.getElement();
if (element != null) {
final GrExpression returnValue;
if (element instanceof GrReturnStatement) {
returnValue = ((GrReturnStatement) element).getReturnValue();
} else if (element instanceof GrExpression && PsiUtil.isExpressionStatement(element)) {
returnValue = (GrExpression) element;
} else {
returnValue = null;
}
return visitor.visitExitPoint(last, returnValue);
}
visited[last.num()] = true;
for (Instruction pred : last.allPredecessors()) {
if (!visited[pred.num()]) {
if (!visitAllExitPointsInner(pred, first, visited, visitor))
return false;
}
}
return true;
}
Aggregations