use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class ParserTest method testConstructor_02.
@Test
public void testConstructor_02() throws Exception {
XtendConstructor constructor = constructor("protected new(int a) throws RuntimeException { super() }");
assertTrue(constructor.getTypeParameters().isEmpty());
assertEquals(1, constructor.getExceptions().size());
assertEquals(1, constructor.getParameters().size());
assertEquals(JvmVisibility.PROTECTED, constructor.getVisibility());
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfSuperInConstructor.
@Test
public void testTypeOfSuperInConstructor() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " super()\n" + "}\n");
XBlockExpression body = (XBlockExpression) constructor.getExpression();
XFeatureCall superCall = (XFeatureCall) body.getExpressions().get(0);
assertEquals("void", getType(superCall).getIdentifier());
assertNull(getExpectedType(superCall));
assertNull(getExpectedReturnType(superCall));
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class TypeProviderTest method testReturnTypeInConstructor_02.
@Test
public void testReturnTypeInConstructor_02() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " return ''.toString\n" + "}\n", false);
XBlockExpression body = (XBlockExpression) constructor.getExpression();
assertEquals("void", getExpectedType(body).getIdentifier());
assertEquals("void", getExpectedReturnType(body).getIdentifier());
XReturnExpression returnExpression = (XReturnExpression) body.getExpressions().get(0);
XMemberFeatureCall toString = (XMemberFeatureCall) returnExpression.getExpression();
assertEquals("void", getExpectedType(toString).getIdentifier());
assertEquals("void", getExpectedReturnType(toString).getIdentifier());
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfThisInConstructor.
@Test
public void testTypeOfThisInConstructor() throws Exception {
XtendConstructor constructor = constructor("new(int a) {\n" + " this()\n" + "}\n" + "new() {}");
XBlockExpression body = (XBlockExpression) constructor.getExpression();
XFeatureCall thisCall = (XFeatureCall) body.getExpressions().get(0);
assertEquals("void", getType(thisCall).getIdentifier());
assertNull(getExpectedType(thisCall));
assertNull(getExpectedReturnType(thisCall));
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendValidationTest method testVarArgMustBeLast_1.
@Test
public void testVarArgMustBeLast_1() throws Exception {
XtendConstructor constr = constructor("new(String... myParam, String x) { }");
helper.assertError(constr, XtendPackage.Literals.XTEND_PARAMETER, INVALID_USE_OF_VAR_ARG);
}
Aggregations