diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index bb4e322a2eec..001016c8924a 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -412,42 +412,44 @@ public class ExceptionUtil { return Collections.emptyList(); } + final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes(); + if (thrownExceptions.length == 0) { + return Collections.emptyList(); + } + final PsiSubstitutor substitutor = result.getSubstitutor(); if (!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) { - final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes(); - if (thrownExceptions.length > 0) { - final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile(); - final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile); - try { - PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false); - final List> candidates = ContainerUtil.mapNotNull( - processor.getResults(), new Function>() { - @Override - public Pair fun(CandidateInfo info) { - PsiElement element = info.getElement(); - if (element instanceof PsiMethod && - MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) && - !MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) { - return Pair.create((PsiMethod)element, info.getSubstitutor()); - } - return null; + final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile(); + final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile); + try { + PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false); + final List> candidates = ContainerUtil.mapNotNull( + processor.getResults(), new Function>() { + @Override + public Pair fun(CandidateInfo info) { + PsiElement element = info.getElement(); + if (element instanceof PsiMethod && + MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) && + !MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) { + return Pair.create((PsiMethod)element, info.getSubstitutor()); } - }); - if (candidates.size() > 1) { - final List ex = collectSubstituted(substitutor, thrownExceptions); - for (Pair pair : candidates) { - final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes(); - if (exceptions.length == 0) { - return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY); - } - retainExceptions(ex, collectSubstituted(pair.second, exceptions)); - } - return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()])); + return null; } + }); + if (candidates.size() > 1) { + final List ex = collectSubstituted(substitutor, thrownExceptions); + for (Pair pair : candidates) { + final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes(); + if (exceptions.length == 0) { + return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY); + } + retainExceptions(ex, collectSubstituted(pair.second, exceptions)); + } + return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()])); } - catch (MethodProcessorSetupFailedException ignore) { - return Collections.emptyList(); - } + } + catch (MethodProcessorSetupFailedException ignore) { + return Collections.emptyList(); } }