void (@NotNull GrTryCatchStatement statement) { final GrCatchClause[] clauses = statement.getCatchClauses(); if (statement.getResourceList() == null && clauses.length == 0 && statement.getFinallyClause() == null) { myHolder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("try.without.catch.finally")).range(statement.getFirstChild()).create(); return; } List<PsiType> usedExceptions = new ArrayList<>(); for (GrCatchClause clause : clauses) { final GrParameter parameter = clause.getParameter(); if (parameter == null) continue; final GrTypeElement typeElement = parameter.getTypeElementGroovy(); PsiType type = typeElement != null ? typeElement.getType() : TypesUtil.createType(CommonClassNames.JAVA_LANG_EXCEPTION, statement); if (typeElement instanceof GrDisjunctionTypeElement) { final GrTypeElement[] elements = ((GrDisjunctionTypeElement)typeElement).getTypeElements(); final PsiType[] types = ContainerUtil.map2Array(elements, PsiType.class, GrTypeElement::getType); List<PsiType> usedInsideDisjunction = new ArrayList<>(); for (int i = 0; i < types.length; i++) { if (checkExceptionUsed(usedExceptions, parameter, elements[i], types[i])) { usedInsideDisjunction.add(types[i]); for (int j = 0; j < types.length; j++) { if (i != j && types[j].isAssignableFrom(types[i])) { myHolder.newAnnotation(HighlightSeverity.WARNING, GroovyBundle.message("unnecessary.type", types[i].getCanonicalText(), types[j].getCanonicalText())).range(elements[i]) .withFix(new GrRemoveExceptionFix(true)).create(); } } } } usedExceptions.addAll(usedInsideDisjunction); } else { if (checkExceptionUsed(usedExceptions, parameter, typeElement, type)) { usedExceptions.add(type); } } } }