use of org.eclipse.xtext.xbase.typesystem.arguments.AssignmentFeatureCallArguments in project xtext-xtend by eclipse.
the class AssignmentFeatureCallArgumentsTest method test_02.
@Test
public void test_02() {
final AssignmentFeatureCallArguments arguments = this.toArguments("String s", "\"\"");
Assert.assertTrue(arguments.hasUnprocessedArguments());
Assert.assertEquals(1, arguments.getArgumentCount());
final IFeatureCallArgumentSlot singleSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertEquals("String", singleSlot.getDeclaredType().getSimpleName());
Assert.assertFalse(singleSlot.isVarArg());
Assert.assertFalse(singleSlot.isSuperfluous());
XExpression _argumentExpression = singleSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
singleSlot.markProcessed();
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.typesystem.arguments.AssignmentFeatureCallArguments in project xtext-xtend by eclipse.
the class AssignmentFeatureCallArgumentsTest method test_01.
@Test
public void test_01() {
final AssignmentFeatureCallArguments arguments = this.toArguments("", "null");
Assert.assertTrue(arguments.hasUnprocessedArguments());
final IFeatureCallArgumentSlot singleSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertNull(singleSlot.getDeclaredType());
Assert.assertFalse(singleSlot.isVarArg());
Assert.assertFalse(singleSlot.isSuperfluous());
XExpression _argumentExpression = singleSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XNullLiteral));
singleSlot.markProcessed();
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.typesystem.arguments.AssignmentFeatureCallArguments in project xtext-xtend by eclipse.
the class AssignmentFeatureCallArgumentsTest method toArguments.
protected AssignmentFeatureCallArguments toArguments(final String type, final String expression) {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("def void m(");
_builder.append(type);
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(expression, "\t");
_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);
final XExpression value = IterableExtensions.<XExpression>head(body.getExpressions());
JvmFormalParameter _head = IterableExtensions.<JvmFormalParameter>head(this._iXtendJvmAssociations.getDirectlyInferredOperation(function).getParameters());
JvmTypeReference _parameterType = null;
if (_head != null) {
_parameterType = _head.getParameterType();
}
final JvmTypeReference declaredType = _parameterType;
if ((declaredType != null)) {
LightweightTypeReference _lightweightTypeReference = this.toLightweightTypeReference(declaredType);
return new AssignmentFeatureCallArguments(value, _lightweightTypeReference);
} else {
return new AssignmentFeatureCallArguments(value, null);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations