Search in sources :

Example 6 with XtendFormalParameter

use of org.eclipse.xtend.core.xtend.XtendFormalParameter in project xtext-xtend by eclipse.

the class ParserTest method testMultiCatch_01.

@Test
public void testMultiCatch_01() throws Exception {
    XtendClass clazz = clazz("class Foo { def void m() { try {} catch(NullPointerException | IllegalArgumentException 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();
    assertFalse(parameter.isExtension());
    JvmSynonymTypeReference parameterType = (JvmSynonymTypeReference) parameter.getParameterType();
    assertEquals(2, parameterType.getReferences().size());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XCatchClause(org.eclipse.xtext.xbase.XCatchClause) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmSynonymTypeReference(org.eclipse.xtext.common.types.JvmSynonymTypeReference) XTryCatchFinallyExpression(org.eclipse.xtext.xbase.XTryCatchFinallyExpression) XtendFormalParameter(org.eclipse.xtend.core.xtend.XtendFormalParameter) Test(org.junit.Test)

Aggregations

XtendClass (org.eclipse.xtend.core.xtend.XtendClass)6 XtendFormalParameter (org.eclipse.xtend.core.xtend.XtendFormalParameter)6 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)5 Test (org.junit.Test)5 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)4 XCatchClause (org.eclipse.xtext.xbase.XCatchClause)4 XTryCatchFinallyExpression (org.eclipse.xtext.xbase.XTryCatchFinallyExpression)4 JvmSynonymTypeReference (org.eclipse.xtext.common.types.JvmSynonymTypeReference)3 XtendField (org.eclipse.xtend.core.xtend.XtendField)2 XClosure (org.eclipse.xtext.xbase.XClosure)2 XForLoopExpression (org.eclipse.xtext.xbase.XForLoopExpression)2 EPackage (org.eclipse.emf.ecore.EPackage)1 RichString (org.eclipse.xtend.core.xtend.RichString)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)1 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)1 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)1 Action (org.eclipse.xtext.Action)1