Search in sources :

Example 1 with XNumberLiteral

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

the class ReorderedFeatureCallArgumentsTest method test_02.

@Test
public void test_02() {
    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 XNumberLiteral));
    Assert.assertEquals("int", 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 XClosure));
    Assert.assertEquals("String", secondSlot.getDeclaredType().getSimpleName());
    Assert.assertFalse(arguments.isProcessed(2));
    secondSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(2));
    Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Also used : XClosure(org.eclipse.xtext.xbase.XClosure) 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 2 with XNumberLiteral

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

the class ReorderedVarArgFeatureCallArgumentsTest method testBug457779_02.

@Test
public void testBug457779_02() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, boolean b, 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 XNumberLiteral));
    final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(1);
    Assert.assertEquals("boolean", secondType.getSimpleName());
    final XExpression third = arguments.getArgument(2);
    Assert.assertTrue((third instanceof XClosure));
    XExpression _expression = ((XClosure) third).getExpression();
    Assert.assertTrue(((XBlockExpression) _expression).getExpressions().isEmpty());
    final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
    Assert.assertEquals("String", 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 : XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XClosure(org.eclipse.xtext.xbase.XClosure) 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 3 with XNumberLiteral

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

the class ReorderedVarArgFeatureCallArgumentsTest method test_02.

@Test
public void test_02() {
    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.assertTrue(firstSlot.isVarArg());
    Assert.assertFalse(firstSlot.isSuperfluous());
    XExpression _argumentExpression = firstSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression instanceof XNumberLiteral));
    Assert.assertEquals("int", 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 XClosure));
    Assert.assertEquals("String", secondSlot.getDeclaredType().getSimpleName());
    Assert.assertFalse(arguments.isProcessed(2));
    secondSlot.markProcessed();
    Assert.assertTrue(arguments.isProcessed(2));
    Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Also used : XClosure(org.eclipse.xtext.xbase.XClosure) 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 4 with XNumberLiteral

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

the class StandardFeatureCallArgumentsTest method test_10.

@Test
public void test_10() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s", "\"\", 1");
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    Assert.assertEquals(3, arguments.getArgumentCount());
    final IFeatureCallArgumentSlot valid = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(valid.isVarArg());
    Assert.assertFalse(valid.isSuperfluous());
    XExpression _argumentExpression = valid.getArgumentExpression();
    Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
    valid.markProcessed();
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    Assert.assertTrue(arguments.isProcessed(1));
    final IFeatureCallArgumentSlot superfluous = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(superfluous.isVarArg());
    Assert.assertTrue(superfluous.isSuperfluous());
    XExpression _argumentExpression_1 = superfluous.getArgumentExpression();
    Assert.assertTrue((_argumentExpression_1 instanceof XNumberLiteral));
    Assert.assertFalse(arguments.isProcessed(2));
    superfluous.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 5 with XNumberLiteral

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

the class StandardFeatureCallArgumentsTest method testBug457779_03.

@Test
public void testBug457779_03() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s, int i", "\"\", 1, true");
    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());
    final XExpression third = arguments.getArgument(2);
    Assert.assertTrue((third instanceof XBooleanLiteral));
    final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
    Assert.assertNull("int", thirdType);
    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) XBooleanLiteral(org.eclipse.xtext.xbase.XBooleanLiteral) 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)

Aggregations

XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)22 XExpression (org.eclipse.xtext.xbase.XExpression)21 IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)21 Test (org.junit.Test)21 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)14 IFeatureCallArgumentSlot (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot)12 XClosure (org.eclipse.xtext.xbase.XClosure)9 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)9 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)4 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)3 EPackage (org.eclipse.emf.ecore.EPackage)1 RichString (org.eclipse.xtend.core.xtend.RichString)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendField (org.eclipse.xtend.core.xtend.XtendField)1 XtendFormalParameter (org.eclipse.xtend.core.xtend.XtendFormalParameter)1 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)1 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)1