protected void _findImplicitReturns(final XSwitchExpression expression, final ImplicitReturnFinder.Acceptor acceptor) { final Consumer<XCasePart> _function = (XCasePart it) -> { this.findImplicitReturns(it.getThen(), acceptor); }; expression.getCases().forEach(_function); this.findImplicitReturns(expression.getDefault(), acceptor); }
public XExpression getThen(final XCasePart casePart, final XSwitchExpression switchExpression) { final XExpression then = casePart.getThen(); if ((then != null)) { return then; } final int casePartIndex = switchExpression.getCases().indexOf(casePart); if ((casePartIndex == (-1))) { return null; } final int count = switchExpression.getCases().size(); if ((casePartIndex == (count - 1))) { return switchExpression.getDefault(); } if (((casePartIndex + 1) < count)) { return this.getThen(switchExpression.getCases().get((casePartIndex + 1)), switchExpression); } return null; } }
return; if (switchExpression.getDefault() != null) { return;
Collection<IEarlyExitComputer.ExitPoint> defaultExit = this.getExitPoints(expression.getDefault()); boolean _isNotEmpty_1 = this.isNotEmpty(defaultExit); boolean _not = (!_isNotEmpty_1);
@Check public void checkRedundantCase(XSwitchExpression switchExpression) { XCasePart casePart = IterableExtensions.last(switchExpression.getCases()); if (casePart == null || !(casePart.isFallThrough() && casePart.getThen() == null)) { return; } if (switchExpression.getDefault() == null) { error("Redundant case.", casePart, null, IssueCodes.REDUNDANT_CASE); } else { warning("Redundant case.", casePart, null, IssueCodes.REDUNDANT_CASE); } }
if (switchExpr.getDefault() != null) { Set<JvmField> initializedInCaseForSure = Sets.newLinkedHashSet(initializedForSure); Set<JvmField> initializedInCaseMaybe = Sets.newLinkedHashSet(initializedMaybe); checkInitializationRec(switchExpr.getDefault(), fields, initializedInCaseForSure, initializedInCaseMaybe, visited); if (initializedAllCasesForSure == null) initializedAllCasesForSure = initializedInCaseForSure;
if (switchExpression.getDefault() == expr) { return false;
if (hasSideEffects(expression.getDefault(), context.branch(buffer))) { return true;
protected Object _doEvaluate(XSwitchExpression switchExpression, IEvaluationContext context, CancelIndicator indicator) { IEvaluationContext forkedContext = context.fork(); Object conditionResult = internalEvaluate(switchExpression.getSwitch(), forkedContext, indicator); String simpleName = featureNameProvider.getSimpleName(switchExpression.getDeclaredParam()); if (simpleName != null) { forkedContext.newValue(QualifiedName.create(simpleName), conditionResult); } for (XCasePart casePart : switchExpression.getCases()) { JvmTypeReference typeGuard = casePart.getTypeGuard(); if (typeGuard != null && switchExpression.getSwitch() == null) throw new IllegalStateException("Switch without expression or implicit 'this' may not use type guards"); if (typeGuard == null || isInstanceoOf(conditionResult, typeGuard)) { if (casePart.getCase() != null) { Object casePartResult = internalEvaluate(casePart.getCase(), forkedContext, indicator); if (Boolean.TRUE.equals(casePartResult) || eq(conditionResult, casePartResult)) { XExpression then = switchExpressions.getThen(casePart, switchExpression); return internalEvaluate(then, forkedContext, indicator); } } else { XExpression then = switchExpressions.getThen(casePart, switchExpression); return internalEvaluate(then, forkedContext, indicator); } } } if (switchExpression.getDefault() != null) { Object defaultResult = internalEvaluate(switchExpression.getDefault(), forkedContext, indicator); return defaultResult; } return getDefaultObjectValue(typeResolver.resolveTypes(switchExpression).getActualType(switchExpression)); }
XExpression then = expr.getDefault(); if (then != null) { if (!fallThroughCases.isEmpty()) {
uncheckedEnumLiterals = new HashSet<JvmEnumerationLiteral>(((JvmEnumerationType) potentialEnumType).getLiterals()); BranchExpressionProcessor branchExpressionProcessor = object.getDefault() == null ? new BranchExpressionProcessor(state, object) { @Override protected String getMessage() { XExpression defaultCase = object.getDefault(); if (defaultCase != null) { allCasePartsState.computeTypes(object.getDefault()); } else if (branchExpressionProcessor != null && !(isEnum && uncheckedEnumLiterals.isEmpty())) { branchExpressionProcessor.commit();
} else if (expression instanceof XSwitchExpression) { XSwitchExpression switchExpression = (XSwitchExpression) expression; if (isDefiniteEarlyExit(switchExpression.getDefault())) { for(XCasePart caseExpression: switchExpression.getCases()) { if (!isDefiniteEarlyExit(caseExpression.getThen())) {
if (expr.getDefault() != null || enumeration) { ILocationData location = getLocationOfDefault(expr); ITreeAppendable defaultAppendable = location != null ? b.trace(location) : b; if (expr.getDefault() != null) { defaultAppendable.openPseudoScope(); executeThenPart(expr, switchResultName, expr.getDefault(), defaultAppendable, isReferenced); defaultAppendable.closeScope(); if (!isEarlyExit(expr.getDefault())) { defaultAppendable.newLine().append("break;"); if (needNullCheck) { b.decreaseIndentation().newLine().append("}"); if (expr.getDefault() != null) { b.append(" else {").increaseIndentation(); executeThenPart(expr, switchResultName, expr.getDefault(), defaultAppendable, isReferenced);
final boolean switchSL = ((!containsBlockExpr) && (!this._nodeModelAccess.nodeForEObject(expr).getText().trim().contains("\n"))); boolean _and = false; if (!(((!containsBlockExpr) && ((!expr.getCases().isEmpty()) || (expr.getDefault() != null))) && (!IterableExtensions.<XCasePart>exists(expr.getCases(), ((Function1<XCasePart, Boolean>) (XCasePart it) -> { return Boolean.valueOf(this._nodeModelAccess.nodeForEObject(it).getText().trim().contains("\n")); }))))) { _and = false; } else { XExpression _default = expr.getDefault(); INode _nodeForEObject = null; if (_default!=null) { XExpression _default_1 = expr.getDefault(); boolean _tripleNotEquals = (_default_1 != null); if (_tripleNotEquals) { it.oneSpace(); }; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _surround = this._formattingDataFactory.surround(this._nodeModelAccess.nodeForEObject(expr.getDefault()), _function_8); format.operator_add(_surround); XExpression _default_2 = expr.getDefault(); boolean _tripleNotEquals_1 = (_default_2 != null); if (_tripleNotEquals_1) { it.oneSpace(); }; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend_3 = this._formattingDataFactory.prepend(this._nodeModelAccess.nodeForEObject(expr.getDefault()), _function_14); format.operator_add(_prepend_3);
final boolean containsBlockExpr = IterableExtensions.<XCasePart>exists(expr.getCases(), _function); final boolean switchSL = ((!containsBlockExpr) && (!this.textRegionExtensions.isMultiline(expr))); final boolean caseSL = ((((!containsBlockExpr) && ((!expr.getCases().isEmpty()) || (expr.getDefault() != null))) && (!IterableExtensions.<XCasePart>exists(expr.getCases(), ((Function1<XCasePart, Boolean>) (XCasePart it) -> { return Boolean.valueOf(this.textRegionExtensions.isMultiline(it)); })))) && (!this.isMultilineOrInNewLine(expr.getDefault()))); final ISemanticRegion open = this.textRegionExtensions.regionFor(expr).keyword("{"); final ISemanticRegion close = this.textRegionExtensions.regionFor(expr).keyword("}"); XExpression _default = expr.getDefault(); boolean _tripleNotEquals = (_default != null); if (_tripleNotEquals) { it.oneSpace(); }; format.<XExpression>format(format.<XExpression>surround(expr.getDefault(), _function_5)); XExpression _default_1 = expr.getDefault(); boolean _tripleNotEquals_1 = (_default_1 != null); if (_tripleNotEquals_1) { it.oneSpace(); }; format.<XExpression>format(format.<XExpression>prepend(expr.getDefault(), _function_10)); }; format.append(format.prepend(open, XbaseFormatterPreferenceKeys.bracesInNewLine), _function_12); if (((!expr.getCases().isEmpty()) || (expr.getDefault() != null))) { final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
if (isIntentionalEarlyExit(switchExpression.getDefault())) { return true;
if (switchStatement.getDefault() != null) { if (first) { generate(switchStatement.getDefault(), it, context); it.newLine(); } else { it.append("else:"); //$NON-NLS-1$ it.increaseIndentation().newLine(); generate(switchStatement.getDefault(), it, context); it.decreaseIndentation().newLine();