use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testMultiCatch_02.
@Test
public void testMultiCatch_02() throws Exception {
XtendClass clazz = clazz("class Foo { def void m() { try {} catch(extension NullPointerException | IllegalArgumentException | IllegalStateException e) {} } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XTryCatchFinallyExpression tryCatch = (XTryCatchFinallyExpression) body.getExpressions().get(0);
XCatchClause singleCatchClause = tryCatch.getCatchClauses().get(0);
XtendFormalParameter parameter = (XtendFormalParameter) singleCatchClause.getDeclaredParam();
assertTrue(parameter.isExtension());
JvmSynonymTypeReference parameterType = (JvmSynonymTypeReference) parameter.getParameterType();
assertEquals(3, parameterType.getReferences().size());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testRichString_02.
@Test
public void testRichString_02() throws Exception {
XtendFunction function = function("def foo() ''''''");
assertTrue(function.getExpression() instanceof RichString);
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testFunctionTypeRef_0.
@Test
public void testFunctionTypeRef_0() throws Exception {
XtendFunction func = function("def =>Boolean foo() { [|true]}");
XFunctionTypeRef type = (XFunctionTypeRef) func.getReturnType();
assertNotNull(type.getReturnType());
assertEquals(0, type.getParamTypes().size());
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testRichString_01.
@Test
public void testRichString_01() throws Exception {
XtendFunction function = function("def foo() ''' foo �'holla'� bar '''");
final RichString richString = (RichString) function.getExpression();
assertTrue(richString.getExpressions().get(0) instanceof RichStringLiteral);
assertTrue(richString.getExpressions().get(1) instanceof XStringLiteral);
assertTrue(richString.getExpressions().get(2) instanceof RichStringLiteral);
}
use of org.eclipse.xtend.core.xtend.XtendFunction in project xtext-xtend by eclipse.
the class ParserTest method testFunction_3.
@Test
public void testFunction_3() throws Exception {
XtendFunction func = function("def foo(String s, Integer i) {s}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(2, func.getParameters().size());
assertEquals("s", func.getParameters().get(0).getName());
assertNotNull(func.getParameters().get(0).getParameterType());
assertEquals("i", func.getParameters().get(1).getName());
assertNotNull(func.getParameters().get(1).getParameterType());
assertNull(func.getReturnType());
assertEquals(0, func.getTypeParameters().size());
}
Aggregations