Search in sources :

Example 11 with XStringLiteral

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

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

the class StandardFeatureCallArgumentsTest method testBug457779_02.

@Test
public void testBug457779_02() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s, int i", "\"\", 1");
    final XExpression first = arguments.getArgument(0);
    Assert.assertTrue((first instanceof XStringLiteral));
    final LightweightTypeReference firstType = arguments.getDeclaredTypeForLambda(0);
    Assert.assertEquals("String", firstType.getSimpleName());
    final XExpression second = arguments.getArgument(1);
    Assert.assertTrue((second instanceof XNumberLiteral));
    final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(1);
    Assert.assertEquals("int", secondType.getSimpleName());
    try {
        arguments.getArgument(2);
        Assert.fail("Expected exception");
    } catch (final Throwable _t) {
        if (_t instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    try {
        arguments.getDeclaredTypeForLambda(2);
        Assert.fail("Expected exception");
    } catch (final Throwable _t_1) {
        if (_t_1 instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t_1);
        }
    }
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XExpression(org.eclipse.xtext.xbase.XExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 13 with XStringLiteral

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

the class StandardFeatureCallArgumentsTest method testBug457779_01.

@Test
public void testBug457779_01() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, int i", "\"\", 1");
    final XExpression first = arguments.getArgument(0);
    Assert.assertNull(first);
    final LightweightTypeReference firstType = arguments.getDeclaredTypeForLambda(0);
    Assert.assertNull(firstType);
    final XExpression second = arguments.getArgument(1);
    Assert.assertTrue((second instanceof XStringLiteral));
    final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(1);
    Assert.assertEquals("String", secondType.getSimpleName());
    final XExpression third = arguments.getArgument(2);
    Assert.assertTrue((third instanceof XNumberLiteral));
    final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
    Assert.assertEquals("int", thirdType.getSimpleName());
    try {
        arguments.getArgument(3);
        Assert.fail("Expected exception");
    } catch (final Throwable _t) {
        if (_t instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    try {
        arguments.getDeclaredTypeForLambda(3);
        Assert.fail("Expected exception");
    } catch (final Throwable _t_1) {
        if (_t_1 instanceof IndexOutOfBoundsException) {
        } else {
            throw Exceptions.sneakyThrow(_t_1);
        }
    }
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XExpression(org.eclipse.xtext.xbase.XExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 14 with XStringLiteral

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

the class StandardFeatureCallArgumentsTest method test_08.

@Test
public void test_08() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, int i", "\"\", 1");
    Assert.assertEquals(3, arguments.getArgumentCount());
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    final IFeatureCallArgumentSlot firstSlot = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(firstSlot.isVarArg());
    Assert.assertFalse(firstSlot.isSuperfluous());
    XExpression _argumentExpression = firstSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
    Assert.assertEquals("String", firstSlot.getDeclaredType().getSimpleName());
    Assert.assertTrue(arguments.isProcessed(0));
    Assert.assertFalse(arguments.isProcessed(1));
    firstSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(1));
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    final IFeatureCallArgumentSlot secondSlot = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(secondSlot.isVarArg());
    Assert.assertFalse(secondSlot.isSuperfluous());
    XExpression _argumentExpression_1 = secondSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression_1 instanceof XNumberLiteral));
    Assert.assertEquals("int", secondSlot.getDeclaredType().getSimpleName());
    Assert.assertFalse(arguments.isProcessed(2));
    secondSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(2));
    Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) XExpression(org.eclipse.xtext.xbase.XExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) IFeatureCallArgumentSlot(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 15 with XStringLiteral

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

the class StandardFeatureCallArgumentsTest method test_04.

@Test
public void test_04() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s, int i", "\"\", 1");
    Assert.assertEquals(2, arguments.getArgumentCount());
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    final IFeatureCallArgumentSlot firstSlot = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(firstSlot.isVarArg());
    Assert.assertFalse(firstSlot.isSuperfluous());
    XExpression _argumentExpression = firstSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
    Assert.assertEquals("String", firstSlot.getDeclaredType().getSimpleName());
    Assert.assertFalse(arguments.isProcessed(0));
    firstSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(0));
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    final IFeatureCallArgumentSlot secondSlot = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(secondSlot.isVarArg());
    Assert.assertFalse(secondSlot.isSuperfluous());
    XExpression _argumentExpression_1 = secondSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression_1 instanceof XNumberLiteral));
    Assert.assertEquals("int", secondSlot.getDeclaredType().getSimpleName());
    Assert.assertFalse(arguments.isProcessed(1));
    secondSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(1));
    Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) XExpression(org.eclipse.xtext.xbase.XExpression) XNumberLiteral(org.eclipse.xtext.xbase.XNumberLiteral) IFeatureCallArgumentSlot(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) 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