Search in sources :

Example 66 with XFeatureCall

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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) XExpression(org.eclipse.xtext.xbase.XExpression) RichStringForLoop(org.eclipse.xtend.core.xtend.RichStringForLoop) Test(org.junit.Test)

Example 67 with XFeatureCall

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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Example 68 with XFeatureCall

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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) RichString(org.eclipse.xtend.core.xtend.RichString) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) RichStringForLoop(org.eclipse.xtend.core.xtend.RichStringForLoop) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 69 with XFeatureCall

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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Example 70 with XFeatureCall

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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) Test(org.junit.Test)

Aggregations

XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)93 Test (org.junit.Test)81 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)72 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)67 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)62 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)29 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)26 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)20 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)19 XExpression (org.eclipse.xtext.xbase.XExpression)14 RichString (org.eclipse.xtend.core.xtend.RichString)7 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)6 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)5 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)5 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)5 EObject (org.eclipse.emf.ecore.EObject)4 XtendField (org.eclipse.xtend.core.xtend.XtendField)4 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)4 ParameterInfo (org.eclipse.jdt.internal.corext.refactoring.ParameterInfo)3