use of org.eclipse.xtext.xbase.XClosure in project xtext-xtend by eclipse.
the class XtendFormatter method builder.
@Override
protected XClosure builder(final List<XExpression> params) {
XClosure _xifexpression = null;
XExpression _last = IterableExtensions.<XExpression>last(params);
boolean _tripleNotEquals = (_last != null);
if (_tripleNotEquals) {
XClosure _xblockexpression = null;
{
final EObject grammarElement = this.textRegionExtensions.grammarElement(IterableExtensions.<XExpression>last(params));
XClosure _xifexpression_1 = null;
if (((Objects.equal(grammarElement, this._xtendGrammarAccess.getXMemberFeatureCallAccess().getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0()) || Objects.equal(grammarElement, this._xtendGrammarAccess.getXFeatureCallAccess().getFeatureCallArgumentsXClosureParserRuleCall_4_0())) || Objects.equal(grammarElement, this._xtendGrammarAccess.getXbaseConstructorCallAccess().getArgumentsXClosureParserRuleCall_5_0()))) {
XExpression _last_1 = IterableExtensions.<XExpression>last(params);
_xifexpression_1 = ((XClosure) _last_1);
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
use of org.eclipse.xtext.xbase.XClosure in project xtext-xtend by eclipse.
the class ReorderedFeatureCallArgumentsTest method test_01.
@Test
public void test_01() {
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 XNumberLiteral));
Assert.assertEquals("int", 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 XClosure));
Assert.assertEquals("String", secondSlot.getDeclaredType().getSimpleName());
Assert.assertFalse(arguments.isProcessed(1));
secondSlot.markProcessed();
Assert.assertTrue(arguments.isProcessed(1));
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.XClosure in project xtext-xtend by eclipse.
the class ReorderedFeatureCallArgumentsTest 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 third = arguments.getArgument(1);
Assert.assertTrue((third instanceof XNumberLiteral));
final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(1);
Assert.assertEquals("int", thirdType.getSimpleName());
final XExpression second = arguments.getArgument(2);
Assert.assertTrue((second instanceof XClosure));
final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(2);
Assert.assertEquals("String", secondType.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);
}
}
}
use of org.eclipse.xtext.xbase.XClosure in project xtext-xtend by eclipse.
the class ReorderedFeatureCallArgumentsTest method testBug457779_02.
@Test
public void testBug457779_02() {
final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s, int i", "[], 1");
final XExpression second = arguments.getArgument(0);
Assert.assertTrue((second instanceof XNumberLiteral));
final LightweightTypeReference secondType = arguments.getDeclaredTypeForLambda(0);
Assert.assertEquals("int", secondType.getSimpleName());
final XExpression first = arguments.getArgument(1);
Assert.assertTrue((first instanceof XClosure));
final LightweightTypeReference firstType = arguments.getDeclaredTypeForLambda(1);
Assert.assertEquals("String", firstType.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.XClosure in project xtext-xtend by eclipse.
the class ReorderedVarArgFeatureCallArgumentsTest method testBug457779_01.
@Test
public void testBug457779_01() {
final IFeatureCallArguments arguments = this.toArgumentsWithReceiver("String s, boolean b, int[] i", "[], 1, [1], true");
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.assertFalse(((XBlockExpression) _expression).getExpressions().isEmpty());
final LightweightTypeReference thirdType = arguments.getDeclaredTypeForLambda(2);
Assert.assertEquals("int", thirdType.getSimpleName());
final XExpression fourth = arguments.getArgument(3);
Assert.assertTrue((fourth instanceof XBooleanLiteral));
final LightweightTypeReference fourthType = arguments.getDeclaredTypeForLambda(3);
Assert.assertEquals("int", fourthType.getSimpleName());
final XExpression fifth = arguments.getArgument(4);
Assert.assertTrue((fifth instanceof XClosure));
XExpression _expression_1 = ((XClosure) fifth).getExpression();
Assert.assertTrue(((XBlockExpression) _expression_1).getExpressions().isEmpty());
final LightweightTypeReference fifthType = arguments.getDeclaredTypeForLambda(4);
Assert.assertEquals("String", fifthType.getSimpleName());
try {
arguments.getArgument(5);
Assert.fail("Expected exception");
} catch (final Throwable _t) {
if (_t instanceof IndexOutOfBoundsException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
try {
arguments.getDeclaredTypeForLambda(5);
Assert.fail("Expected exception");
} catch (final Throwable _t_1) {
if (_t_1 instanceof IndexOutOfBoundsException) {
} else {
throw Exceptions.sneakyThrow(_t_1);
}
}
}
Aggregations