Search in sources :

Example 21 with XStringLiteral

use of org.eclipse.xtext.xbase.XStringLiteral 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 22 with XStringLiteral

use of org.eclipse.xtext.xbase.XStringLiteral in project xtext-xtend by eclipse.

the class ParserTest method testXtendField_04.

@Test
public void testXtendField_04() throws Exception {
    XtendClass clazz = clazz("class Foo { " + "  @com.google.inject.Inject val foo = 'foo'" + "  @com.google.inject.Inject var java.util.List myList" + "}");
    assertEquals(2, clazz.getMembers().size());
    XtendField field = (XtendField) clazz.getMembers().get(0);
    assertNull(field.getType());
    assertEquals("foo", field.getName());
    assertTrue(field.getInitialValue() instanceof XStringLiteral);
    field = (XtendField) clazz.getMembers().get(1);
    assertEquals("java.util.List", field.getType().getType().getIdentifier());
    assertEquals("myList", field.getName());
    assertEquals("java.util.List", field.getType().getIdentifier());
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Aggregations

XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)22 Test (org.junit.Test)21 XExpression (org.eclipse.xtext.xbase.XExpression)17 IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)16 XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)14 IFeatureCallArgumentSlot (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot)11 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)6 RichString (org.eclipse.xtend.core.xtend.RichString)3 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)2 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)2 XtendField (org.eclipse.xtend.core.xtend.XtendField)2 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)2 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 RichStringForLoop (org.eclipse.xtend.core.xtend.RichStringForLoop)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendFormalParameter (org.eclipse.xtend.core.xtend.XtendFormalParameter)1