use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testRichStringFOR_01.
@Test
public void testRichStringFOR_01() throws Exception {
XtendFunction function = function("def withForLoop() '''�FOR i: 1..10��i��ENDFOR�'''");
final RichString richString = (RichString) function.getExpression();
final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(1);
assertTrue(rsFor.getForExpression() instanceof XBinaryOperation);
assertEquals("i", rsFor.getDeclaredParam().getName());
RichString eachRichString = (RichString) rsFor.getEachExpression();
assertEquals(3, eachRichString.getExpressions().size());
XExpression variableReference = eachRichString.getExpressions().get(1);
assertTrue(variableReference instanceof XFeatureCall);
assertSame(rsFor.getDeclaredParam(), ((XAbstractFeatureCall) variableReference).getFeature());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_4.
@Test
public void testFunction_4() throws Exception {
XtendFunction func = function("def foo() {foo}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(0, func.getParameters().size());
assertNull(func.getReturnType());
assertFalse(func.isDispatch());
assertEquals(0, func.getTypeParameters().size());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testRichStringFOR_02.
@Test
public void testRichStringFOR_02() throws Exception {
XtendFunction function = function("def withForLoop() '''�FOR i: 1..10 BEFORE 'a' SEPARATOR '\t' AFTER i��ENDFOR�'''");
final RichString richString = (RichString) function.getExpression();
final RichStringForLoop rsFor = (RichStringForLoop) richString.getExpressions().get(1);
assertTrue(rsFor.getForExpression() instanceof XBinaryOperation);
assertEquals("i", rsFor.getDeclaredParam().getName());
assertTrue(rsFor.getSeparator() instanceof XStringLiteral);
assertTrue(rsFor.getBefore() instanceof XStringLiteral);
assertTrue(rsFor.getAfter() instanceof XFeatureCall);
assertTrue(((XAbstractFeatureCall) rsFor.getAfter()).getFeature().eIsProxy());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_5.
@Test
public void testFunction_5() throws Exception {
XtendFunction func = function("def dispatch foo(String s) {foo('x')}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(1, func.getParameters().size());
assertNull(func.getReturnType());
assertTrue(func.isDispatch());
assertEquals(0, func.getTypeParameters().size());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_7.
@Test
public void testFunction_7() throws Exception {
XtendFunction func = function("override foo() { foo}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(0, func.getParameters().size());
assertNull(func.getReturnType());
assertTrue(func.isOverride());
assertFalse(func.isDispatch());
assertEquals(0, func.getTypeParameters().size());
}
Aggregations