Search in sources :

Example 6 with RichStringLiteral

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

the class ParserTest method testRichStringWithComment_01.

@Test
public void testRichStringWithComment_01() throws Exception {
    XtendFunction function = function("def foo() '''first� /* ml comment\n */ �� sl_comment \nsecond'''");
    assertTrue(function.getExpression() instanceof RichString);
    RichString richString = (RichString) function.getExpression();
    assertEquals(2, richString.getExpressions().size());
    RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
    assertEquals("first", first.getValue());
    RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
    assertEquals("second", second.getValue());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) Test(org.junit.Test)

Example 7 with RichStringLiteral

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

the class ParserTest method testRichStringWithComment_00.

@Test
public void testRichStringWithComment_00() throws Exception {
    XtendFunction function = function("def foo() '''first��� comment \nsecond'''");
    assertTrue(function.getExpression() instanceof RichString);
    RichString richString = (RichString) function.getExpression();
    assertEquals(2, richString.getExpressions().size());
    RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
    assertEquals("first", first.getValue());
    RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
    assertEquals("second", second.getValue());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) Test(org.junit.Test)

Example 8 with RichStringLiteral

use of org.eclipse.xtend.core.xtend.RichStringLiteral 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);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral) RichString(org.eclipse.xtend.core.xtend.RichString) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) RichStringIf(org.eclipse.xtend.core.xtend.RichStringIf) Test(org.junit.Test)

Example 9 with RichStringLiteral

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

Example 10 with RichStringLiteral

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

Aggregations

RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)14 RichString (org.eclipse.xtend.core.xtend.RichString)11 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)9 Test (org.junit.Test)8 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3 EObject (org.eclipse.emf.ecore.EObject)2 RichStringIf (org.eclipse.xtend.core.xtend.RichStringIf)2 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 INode (org.eclipse.xtext.nodemodel.INode)2 ITextRegion (org.eclipse.xtext.util.ITextRegion)2 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)2 XExpression (org.eclipse.xtext.xbase.XExpression)2 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)2 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)2 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 RichStringElseIf (org.eclipse.xtend.core.xtend.RichStringElseIf)1 RichStringForLoop (org.eclipse.xtend.core.xtend.RichStringForLoop)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1