mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-02 03:07:47 +07:00
redundant throws: move collecting unthrown exceptions to annotator
this should make running inspections without redundant throws much faster as method bodies won't be checked for thrown exceptions
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.codeInspection.reference;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -27,9 +26,6 @@ import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
|
||||
@Override
|
||||
@@ -137,29 +133,7 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(aClass);
|
||||
if (interfaceMethod != null) {
|
||||
refFrom.addReference(refFrom.getRefManager().getReference(interfaceMethod), interfaceMethod, psiFrom, false, true, null);
|
||||
|
||||
PsiElement body = null;
|
||||
PsiElement topElement = null;
|
||||
if (expression instanceof PsiLambdaExpression) {
|
||||
body = ((PsiLambdaExpression)expression).getBody();
|
||||
topElement = expression;
|
||||
}
|
||||
else {
|
||||
final PsiElement resolve = ((PsiMethodReferenceExpression)expression).resolve();
|
||||
if (resolve instanceof PsiMethod) {
|
||||
body = ((PsiMethod)resolve).getBody();
|
||||
topElement = resolve;
|
||||
}
|
||||
}
|
||||
|
||||
final Collection<PsiClassType> exceptionTypes = body != null ? ExceptionUtil.collectUnhandledExceptions(body, topElement, false)
|
||||
: Collections.emptyList();
|
||||
RefElement refResolved = refFrom.getRefManager().getReference(interfaceMethod);
|
||||
if (refResolved instanceof RefMethodImpl) {
|
||||
for (final PsiClassType exceptionType : exceptionTypes) {
|
||||
((RefMethodImpl)refResolved).updateThrowsList(exceptionType);
|
||||
}
|
||||
}
|
||||
refFrom.getRefManager().fireNodeMarkedReferenced(interfaceMethod, expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user