use of org.eclipse.xtend.core.xtend.RichString in project xtext-xtend by eclipse.
the class ParserTest method testRichStringIF_01.
@Test
public void testRichStringIF_01() throws Exception {
XtendFunction function = function("def foo() ''' foo �IF true� wurst �IF false� brot �ELSE� machine �ENDIF� bar �ENDIF�'''");
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);
final RichString then = (RichString) rsIf.getThen();
assertEquals(3, then.getExpressions().size());
RichStringIf innerIf = (RichStringIf) then.getExpressions().get(1);
assertTrue(innerIf.getIf() instanceof XBooleanLiteral);
assertTrue(innerIf.getElse() instanceof RichString);
assertTrue(rsIf.getElse() == null);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.RichString in project xtext-xtend by eclipse.
the class ParserTest method testRichString_02.
@Test
public void testRichString_02() throws Exception {
XtendFunction function = function("def foo() ''''''");
assertTrue(function.getExpression() instanceof RichString);
}
use of org.eclipse.xtend.core.xtend.RichString in project xtext-xtend by eclipse.
the class ParserTest method testRichString_01.
@Test
public void testRichString_01() throws Exception {
XtendFunction function = function("def foo() ''' foo �'holla'� bar '''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XStringLiteral);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.RichString in project xtext-xtend by eclipse.
the class ParserTest method testRichStringFOR_03.
@Test
public void testRichStringFOR_03() throws Exception {
XtendFunction function = function("def withForLoop(String it) '''�it��val it = 1..10��FOR i: it SEPARATOR it��ENDFOR�'''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XFeatureCall);
JvmOperation operation = associations.getDirectlyInferredOperation(function);
assertSame(operation.getParameters().get(0), ((XAbstractFeatureCall) richString.getExpressions().get(1)).getFeature());
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(3) instanceof XVariableDeclaration);
assertTrue(richString.getExpressions().get(4) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(5) instanceof RichStringForLoop);
final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(5);
assertTrue(rsFor.getForExpression() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getForExpression()).getFeature());
assertEquals("i", rsFor.getDeclaredParam().getName());
assertTrue(rsFor.getSeparator() instanceof XFeatureCall);
assertSame(richString.getExpressions().get(3), ((XAbstractFeatureCall) rsFor.getSeparator()).getFeature());
}
use of org.eclipse.xtend.core.xtend.RichString in project xtext-xtend by eclipse.
the class AbstractRichStringTest method richString.
protected RichString richString(String string) throws Exception {
XtendClass clazz = clazz(getPrefix() + string + "}");
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
return (RichString) function.getExpression();
}
Aggregations