Search in sources :

Example 1 with ResolvedUnionType

use of com.github.javaparser.resolution.types.ResolvedUnionType in project javaparser by javaparser.

the class JavaParserFacadeResolutionTest method solveMultiCatchType.

@Test
public void solveMultiCatchType() {
    String code = "class A {\n" + "        public void foo() {\n" + "            try {\n" + "                \n" + "            } catch (IllegalStateException | IllegalArgumentException e) {\n" + "                \n" + "            }\n" + "        }\n" + "    }";
    CompilationUnit cu = parseWithTypeSolver(code);
    CatchClause catchClause = Navigator.findNodeOfGivenClass(cu, CatchClause.class);
    Type jpType = catchClause.getParameter().getType();
    ResolvedType jssType = jpType.resolve();
    assertEquals(true, jssType instanceof ResolvedUnionType);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ResolvedUnionType(com.github.javaparser.resolution.types.ResolvedUnionType) ResolvedType(com.github.javaparser.resolution.types.ResolvedType) Type(com.github.javaparser.ast.type.Type) ResolvedReferenceType(com.github.javaparser.resolution.types.ResolvedReferenceType) CatchClause(com.github.javaparser.ast.stmt.CatchClause) ResolvedUnionType(com.github.javaparser.resolution.types.ResolvedUnionType) ResolvedType(com.github.javaparser.resolution.types.ResolvedType) Test(org.junit.Test)

Aggregations

CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 CatchClause (com.github.javaparser.ast.stmt.CatchClause)1 Type (com.github.javaparser.ast.type.Type)1 ResolvedReferenceType (com.github.javaparser.resolution.types.ResolvedReferenceType)1 ResolvedType (com.github.javaparser.resolution.types.ResolvedType)1 ResolvedUnionType (com.github.javaparser.resolution.types.ResolvedUnionType)1 Test (org.junit.Test)1