@Override public boolean isDefiniteEarlyExit(XExpression expression) { if (super.isDefiniteEarlyExit(expression)) { return true; } return isEarlyExitSARLStatement(expression); }
@Override public boolean isIntentionalEarlyExit(XExpression expression) { if (super.isIntentionalEarlyExit(expression)) { return true; } return isEarlyExitSARLStatement(expression); }
public List<LightweightTypeReference> getThrownExceptions(XExpression obj, IResolvedTypes types, ITypeReferenceOwner owner) { if (obj == null) { return Collections.emptyList(); } final List<LightweightTypeReference> result = Lists.newArrayListWithExpectedSize(2); ThrownExceptionDelegate delegate = createDelegate(result, types, owner); Switch<Boolean> collector = createThrownExceptionCollector(delegate); delegate.collectWith(collector); delegate.collectThrownExceptions(obj); return result; }
@Override public IThrownExceptionDelegate catchExceptions(List<LightweightTypeReference> caughtExceptions) { if (caughtExceptions.isEmpty()) { return this; } FilteringThrownExceptionDelegate delegate = new FilteringThrownExceptionDelegate(this, caughtExceptions); Switch<Boolean> collector = createThrownExceptionCollector(delegate); delegate.collectWith(collector); return delegate; }
@Override public List<LightweightTypeReference> getThrownExceptions(XExpression obj) { return getServices().getEarlyExitComputer().getThrownExceptions(obj, this, this.getReferenceOwner()); }
return isDefiniteEarlyExit(ifExpression.getThen()) && isDefiniteEarlyExit(ifExpression.getElse()); } else if (expression instanceof XSwitchExpression) { XSwitchExpression switchExpression = (XSwitchExpression) expression; if (isDefiniteEarlyExit(switchExpression.getDefault())) { for(XCasePart caseExpression: switchExpression.getCases()) { if (!isDefiniteEarlyExit(caseExpression.getThen())) { return false; } else if (expression instanceof XTryCatchFinallyExpression) { XTryCatchFinallyExpression tryExpression = (XTryCatchFinallyExpression) expression; if (isDefiniteEarlyExit(tryExpression.getFinallyExpression())) { return true; if (isDefiniteEarlyExit(tryExpression.getExpression())) { for(XCatchClause catchClause: tryExpression.getCatchClauses()) { if (!isDefiniteEarlyExit(catchClause.getExpression())) { return false; List<XExpression> expressions = ((XBlockExpression) expression).getExpressions(); for(int i = expressions.size() - 1; i >= 0; i--) { if (isDefiniteEarlyExit(expressions.get(i))) { return true; return isDefiniteEarlyExit(((XSynchronizedExpression) expression).getExpression());
List<XExpression> children = block.getExpressions(); for(XExpression child: children) { if (isIntentionalEarlyExit(child)) { return true; return isIntentionalEarlyExit(((XIfExpression) expression).getThen()) || isIntentionalEarlyExit(((XIfExpression) expression).getElse()); } else if (expression instanceof XSwitchExpression) { XSwitchExpression switchExpression = (XSwitchExpression) expression; for(XCasePart caseExpression: switchExpression.getCases()) { if (isIntentionalEarlyExit(caseExpression.getThen())) { return true; if (isIntentionalEarlyExit(switchExpression.getDefault())) { return true; if (isIntentionalEarlyExit(tryCatchFinally.getExpression())) { for(XCatchClause catchClause: tryCatchFinally.getCatchClauses()) { if (!isIntentionalEarlyExit(catchClause.getExpression())) return false; return isIntentionalEarlyExit(((XAbstractWhileExpression) expression).getBody()); } else if (expression instanceof XForLoopExpression) { return isIntentionalEarlyExit(((XForLoopExpression) expression).getEachExpression()); } else if (expression instanceof XBasicForLoopExpression) { return isIntentionalEarlyExit(((XBasicForLoopExpression) expression).getEachExpression()); } else if (expression instanceof XSynchronizedExpression) { return isIntentionalEarlyExit(((XSynchronizedExpression) expression).getExpression());
protected boolean isDefiniteEarlyExit(XExpression expression) { CommonTypeComputationServices services = getState().getReferenceOwner().getServices(); return services.getEarlyExitComputer().isDefiniteEarlyExit(expression); }
/** * Returns <code>true</code> for expressions that seem to be early exit expressions, e.g. * <pre> * while(condition) { * if (anotherCondition) * return value * changeResultOfFirstCondition * } * </pre> */ protected boolean isIntentionalEarlyExit(/* @Nullable */ XExpression expression) { ExtendedEarlyExitComputer earlyExitComputer = getReferenceOwner().getServices().getEarlyExitComputer(); return earlyExitComputer.isIntentionalEarlyExit(expression); }
if (earlyExitComputer.isDefiniteEarlyExit(computedType.getExpression())) { AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl( Severity.ERROR,