@Check public void checkDeadCode(XWhileExpression loop) { XExpression predicate = loop.getPredicate(); if (!earlyExitComputer.isEarlyExit(predicate)) { Optional<BooleanResult> result = getBooleanResult(predicate); if (result.isPresent()) { BooleanResult booleanResult = result.get(); markConstantBooleanCondition(predicate, booleanResult, true); if (booleanResult.isCompileTimeConstant() && !booleanResult.getValue().or(Boolean.TRUE)) { markAsDeadCode(loop.getBody()); } } } else { markAsDeadCode(loop.getBody()); } }
protected Object _doEvaluate(XWhileExpression whileLoop, IEvaluationContext context, CancelIndicator indicator) { Object condition = internalEvaluate(whileLoop.getPredicate(), context, indicator); while (Boolean.TRUE.equals(condition)) { internalEvaluate(whileLoop.getBody(), context, indicator); condition = internalEvaluate(whileLoop.getPredicate(), context, indicator); } return null; }
protected Collection<IEarlyExitComputer.ExitPoint> _exitPoints(final XWhileExpression expression) { Collection<IEarlyExitComputer.ExitPoint> exitPoints = this.getExitPoints(expression.getPredicate()); boolean _isNotEmpty = this.isNotEmpty(exitPoints); if (_isNotEmpty) { return exitPoints; } boolean _isBooleanConstant = this.isBooleanConstant(expression.getPredicate(), true); if (_isBooleanConstant) { exitPoints = this.getExitPoints(expression.getBody()); boolean _isNotEmpty_1 = this.isNotEmpty(exitPoints); if (_isNotEmpty_1) { return exitPoints; } IEarlyExitComputer.ExitPoint _exitPoint = new IEarlyExitComputer.ExitPoint(expression, false); return Collections.<IEarlyExitComputer.ExitPoint>singletonList(_exitPoint); } return Collections.<IEarlyExitComputer.ExitPoint>emptyList(); }
/** Generate the given object. * * @param whileLoop the while-loop. * @param it the target for the generated content. * @param context the context. * @return the last statement in the loop or {@code null}. */ protected XExpression _generate(XWhileExpression whileLoop, IAppendable it, IExtraLanguageGeneratorContext context) { it.append("while "); //$NON-NLS-1$ generate(whileLoop.getPredicate(), it, context); it.append(":"); //$NON-NLS-1$ it.increaseIndentation().newLine(); final XExpression last = generate(whileLoop.getBody(), it, context); it.decreaseIndentation(); return last; }
protected void _format(final XWhileExpression expr, @Extension final IFormattableDocument format) { format.append(this.textRegionExtensions.regionFor(expr).keyword("while"), XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML); final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> { it.noSpace(); }; final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> { it.noSpace(); }; format.<XExpression>format(format.<XExpression>append(format.<XExpression>prepend(expr.getPredicate(), _function), _function_1)); this.formatBody(expr.getBody(), true, format); }
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _surround = this._formattingDataFactory.surround(this._nodeModelAccess.nodeForEObject(expr.getPredicate()), _function_1, _function_2); format.operator_add(_surround); final INode body = this._nodeModelAccess.nodeForEObject(expr.getBody()); XExpression _body = expr.getBody(); if ((_body instanceof XBlockExpression)) { final Procedure1<FormattingDataInit> _function_3 = (FormattingDataInit it) -> { this.format(expr.getBody(), format);
feeder.accept(grammarAccess.getXWhileExpressionAccess().getBodyXExpressionParserRuleCall_5_0(), semanticObject.getBody()); feeder.finish();