mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
[functional expressions search] check method equality when applicable (IDEA-276298)
otherwise unrelated lambdas/method references may land in results when intermediate inheritors contain default methods GitOrigin-RevId: aa5baae37ff676ca477ca41d82b782c42d5fda6c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d43848c086
commit
f33a1f5426
@@ -39,10 +39,7 @@ import com.intellij.psi.search.searches.FunctionalExpressionSearch.SearchParamet
|
||||
import com.intellij.psi.stubs.StubIndex;
|
||||
import com.intellij.psi.stubs.StubTextInconsistencyException;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Processors;
|
||||
import com.intellij.util.ThreeState;
|
||||
@@ -94,6 +91,11 @@ public final class JavaFunctionalExpressionSearcher extends QueryExecutorBase<Ps
|
||||
PsiMethod saMethod = Objects.requireNonNull(LambdaUtil.getFunctionalInterfaceMethod(samClass));
|
||||
PsiType samType = saMethod.getReturnType();
|
||||
if (samType == null) continue;
|
||||
if (session.method != null &&
|
||||
!saMethod.equals(session.method) &&
|
||||
!MethodSignatureUtil.isSuperMethod(saMethod, session.method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SearchScope scope = psiSearchHelper.getUseScope(samClass).intersectWith(session.scope);
|
||||
descriptors.add(new SamDescriptor(samClass, saMethod, samType, GlobalSearchScopeUtil.toGlobalSearchScope(scope, project)));
|
||||
@@ -461,10 +463,12 @@ public final class JavaFunctionalExpressionSearcher extends QueryExecutorBase<Ps
|
||||
private final AtomicInteger sureExprsAfterLightCheck = new AtomicInteger();
|
||||
private final AtomicInteger exprsToHeavyCheck = new AtomicInteger();
|
||||
private final Set<VirtualFile> filesLookedInside = ContainerUtil.newConcurrentSet();
|
||||
private final @Nullable PsiMethod method;
|
||||
|
||||
public Session(@NotNull SearchParameters parameters, @NotNull Processor<? super PsiFunctionalExpression> consumer) {
|
||||
this.consumer = consumer;
|
||||
elementToSearch = parameters.getElementToSearch();
|
||||
method = parameters.getMethod();
|
||||
project = parameters.getProject();
|
||||
psiManager = PsiManager.getInstance(project);
|
||||
scope = parameters.getEffectiveSearchScope();
|
||||
|
||||
Reference in New Issue
Block a user