void (@NotNull PsiMethod method) { super.visitMethod(method); final PsiReferenceList throwsList = method.getThrowsList(); if (!throwsList.isPhysical()) { return; } final PsiJavaCodeReferenceElement[] throwsReferences = throwsList.getReferenceElements(); if (throwsReferences.length == 0) { return; } final PsiCodeBlock body = method.getBody(); if (body == null) { return; } if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) { return; } final Set<PsiClassType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(body); final PsiClassType[] referencedExceptions = throwsList.getReferencedTypes(); final Set<PsiType> exceptionsDeclared = new HashSet<>(referencedExceptions.length); ContainerUtil.addAll(exceptionsDeclared, referencedExceptions); final int referencedExceptionsLength = referencedExceptions.length; for (int i = 0; i < referencedExceptionsLength; i++) { final PsiClassType referencedException = referencedExceptions[i]; if (onlyWarnOnRootExceptions) { if (!ExceptionUtils.isGenericExceptionClass( referencedException)) { continue; } } final List<SmartTypePointer> exceptionsMasked = new ArrayList<>(); final SmartTypePointerManager pointerManager = SmartTypePointerManager.getInstance(body.getProject()); for (PsiType exceptionThrown : exceptionsThrown) { if (referencedException.isAssignableFrom(exceptionThrown) && !exceptionsDeclared.contains(exceptionThrown)) { exceptionsMasked.add(pointerManager.createSmartTypePointer(exceptionThrown)); } } if (!exceptionsMasked.isEmpty()) { int numberOfHiddenExceptions = exceptionsMasked.size(); if (numberOfHiddenExceptions > hiddenExceptionsThreshold) { continue; } final PsiJavaCodeReferenceElement throwsReference = throwsReferences[i]; final boolean originalNeeded = exceptionsThrown.contains(referencedException); if (ignoreThrown && originalNeeded) { continue; } registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded), throwsReference); } } }