Search in sources :

Example 11 with IFeatureCallArguments

use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.

the class StandardFeatureCallArgumentsTest method test_01.

@Test
public void test_01() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("", "");
    Assert.assertFalse(arguments.hasUnprocessedArguments());
    Assert.assertEquals(0, arguments.getArgumentCount());
}
Also used : IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 12 with IFeatureCallArguments

use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.

the class StandardFeatureCallArgumentsTest method test_02.

@Test(expected = NoSuchElementException.class)
public void test_02() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("", "");
    arguments.getNextUnprocessedArgumentSlot();
}
Also used : IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 13 with IFeatureCallArguments

use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.

the class StandardFeatureCallArgumentsTest method test_03.

@Test
public void test_03() {
    final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s", "\"\"");
    Assert.assertTrue(arguments.hasUnprocessedArguments());
    Assert.assertEquals(1, arguments.getArgumentCount());
    final IFeatureCallArgumentSlot singleSlot = arguments.getNextUnprocessedArgumentSlot();
    Assert.assertFalse(singleSlot.isVarArg());
    Assert.assertFalse(singleSlot.isSuperfluous());
    XExpression _argumentExpression = singleSlot.getArgumentExpression();
    Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
    Assert.assertEquals("String", singleSlot.getDeclaredType().getSimpleName());
    singleSlot.markProcessed();
    Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Also used : XStringLiteral(org.eclipse.xtext.xbase.XStringLiteral) XExpression(org.eclipse.xtext.xbase.XExpression) IFeatureCallArgumentSlot(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 14 with IFeatureCallArguments

use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.

the class StandardFeatureCallArgumentsTest method test_06.

@Test(expected = NoSuchElementException.class)
public void test_06() {
    final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("", "");
    arguments.getNextUnprocessedArgumentSlot();
}
Also used : IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments) Test(org.junit.Test)

Example 15 with IFeatureCallArguments

use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.

the class StandardFeatureCallArgumentsTest method toArguments.

protected IFeatureCallArguments toArguments(final String signature, final String invocation, final boolean receiver) {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("def void m(");
        _builder.append(signature);
        _builder.append(") {");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("m(");
        _builder.append(invocation, "\t");
        _builder.append(")");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
        final String functionString = _builder.toString();
        final XtendFunction function = this.function(functionString);
        XExpression _expression = function.getExpression();
        final XBlockExpression body = ((XBlockExpression) _expression);
        XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions());
        final XFeatureCall featureCall = ((XFeatureCall) _head);
        final EList<XExpression> arguments = featureCall.getFeatureCallArguments();
        final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function);
        final IFeatureCallArguments result = this.factory.createStandardArguments(arguments, operation.getParameters(), receiver, this.getOwner());
        Class<? extends IFeatureCallArguments> _class = result.getClass();
        boolean _equals = Objects.equal(_class, StandardFeatureCallArguments.class);
        Assert.assertTrue(_equals);
        return result;
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) IFeatureCallArguments(org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)

Aggregations

IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)53 Test (org.junit.Test)49 XExpression (org.eclipse.xtext.xbase.XExpression)28 XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)21 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)16 IFeatureCallArgumentSlot (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArgumentSlot)14 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)10 XClosure (org.eclipse.xtext.xbase.XClosure)8 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)6 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)4 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)4 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3