use of org.eclipse.xtend.core.xtend.RichStringElseIf in project xtext-xtend by eclipse.
the class ParserTest method testRichStringIF_00.
@Test
public void testRichStringIF_00() throws Exception {
XtendFunction function = function("def foo() ''' foo �IF true� wurst �ELSEIF null==3� brot �ELSE� machine �ENDIF� bar '''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
final RichStringIf rsIf = (RichStringIf) richString.getExpressions().get(1);
assertTrue(rsIf.getIf() instanceof XBooleanLiteral);
assertTrue(rsIf.getThen() instanceof RichString);
assertEquals(1, rsIf.getElseIfs().size());
RichStringElseIf elseIf = rsIf.getElseIfs().get(0);
assertTrue(elseIf.getIf() instanceof XBinaryOperation);
assertTrue(elseIf.getThen() instanceof RichString);
assertTrue(rsIf.getElse() instanceof RichString);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.RichStringElseIf in project xtext-xtend by eclipse.
the class XtendTypeComputer method _computeTypes.
protected void _computeTypes(RichStringIf object, ITypeComputationState state) {
LightweightTypeReference charSequence = getRawTypeForName(CharSequence.class, state);
LightweightTypeReference booleanType = getRawTypeForName(Boolean.TYPE, state);
ITypeComputationState conditionExpectation = state.withExpectation(booleanType);
XExpression condition = object.getIf();
conditionExpectation.computeTypes(condition);
XExpression thenExpression = object.getThen();
ITypeComputationState thenState = reassignCheckedType(condition, thenExpression, state);
thenState.withExpectation(charSequence).computeTypes(thenExpression);
for (RichStringElseIf elseIf : object.getElseIfs()) {
state.withExpectation(booleanType).computeTypes(elseIf.getIf());
ITypeComputationState elseState = reassignCheckedType(elseIf.getIf(), elseIf.getThen(), state);
elseState.withExpectation(charSequence).computeTypes(elseIf.getThen());
}
state.withExpectation(charSequence).computeTypes(object.getElse());
state.acceptActualType(charSequence);
}
use of org.eclipse.xtend.core.xtend.RichStringElseIf in project xtext-xtend by eclipse.
the class RichStringFormatter method _format.
protected void _format(final RichStringIf expr, @Extension final IFormattableDocument doc) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
doc.append(doc.prepend(this._iTextRegionExtensions.regionFor(expr).keyword("IF"), _function), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
doc.<RichStringElseIf>append(IterableExtensions.<RichStringElseIf>last(expr.getElseIfs()), _function_2);
this.formatIntoSingleLine(doc, expr.getIf());
this.format(expr.getThen(), doc);
EList<RichStringElseIf> _elseIfs = expr.getElseIfs();
for (final RichStringElseIf elseif : _elseIfs) {
this.format(elseif, doc);
}
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
doc.surround(this._iTextRegionExtensions.regionFor(expr).keyword("ELSE"), _function_3);
this.format(expr.getElse(), doc);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
doc.surround(this._iTextRegionExtensions.regionFor(expr).keyword("ENDIF"), _function_4);
}
use of org.eclipse.xtend.core.xtend.RichStringElseIf in project xtext-xtend by eclipse.
the class ElseIfConditionImpl method setRichStringElseIf.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRichStringElseIf(RichStringElseIf newRichStringElseIf) {
RichStringElseIf oldRichStringElseIf = richStringElseIf;
richStringElseIf = newRichStringElseIf;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ProcessedRichStringPackage.ELSE_IF_CONDITION__RICH_STRING_ELSE_IF, oldRichStringElseIf, richStringElseIf));
}
Aggregations