use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.
the class ReorderedVarArgFeatureCallArgumentsTest 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.createVarArgArguments(arguments, operation.getParameters(), receiver, this.getOwner());
Class<? extends IFeatureCallArguments> _class = result.getClass();
boolean _equals = Objects.equal(_class, ReorderedVarArgFeatureCallArguments.class);
Assert.assertTrue(_equals);
return result;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.
the class StandardFeatureCallArgumentsTest method test_05.
@Test
public void test_05() {
final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("", "");
Assert.assertFalse(arguments.hasUnprocessedArguments());
Assert.assertEquals(1, arguments.getArgumentCount());
}
use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments 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);
}
}
}
use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments in project xtext-xtend by eclipse.
the class StandardFeatureCallArgumentsTest method test_11.
@Test
public void test_11() {
final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s", "");
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments 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);
}
}
}
Aggregations