Search in sources :

Example 1 with RichStringForLoop

use of org.eclipse.xtend.core.xtend.RichStringForLoop 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());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration) RichString(org.eclipse.xtend.core.xtend.RichString) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) RichStringForLoop(org.eclipse.xtend.core.xtend.RichStringForLoop) Test(org.junit.Test)

Example 2 with RichStringForLoop

use of org.eclipse.xtend.core.xtend.RichStringForLoop in project xtext-xtend by eclipse.

the class ForLoopStartImpl method setLoop.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setLoop(RichStringForLoop newLoop) {
    RichStringForLoop oldLoop = loop;
    loop = newLoop;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ProcessedRichStringPackage.FOR_LOOP_START__LOOP, oldLoop, loop));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) RichStringForLoop(org.eclipse.xtend.core.xtend.RichStringForLoop)

Example 3 with RichStringForLoop

use of org.eclipse.xtend.core.xtend.RichStringForLoop 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 4 with RichStringForLoop

use of org.eclipse.xtend.core.xtend.RichStringForLoop 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)

Aggregations

RichStringForLoop (org.eclipse.xtend.core.xtend.RichStringForLoop)4 RichString (org.eclipse.xtend.core.xtend.RichString)3 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)3 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)3 Test (org.junit.Test)3 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)1 XExpression (org.eclipse.xtext.xbase.XExpression)1 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)1 XVariableDeclaration (org.eclipse.xtext.xbase.XVariableDeclaration)1