mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
[kotlin] direct function overrides search
wrap search parameters to forbid kotlin class inheritance search from java overriding methods search, cause kotlin method overrides should be found separately and without LC GitOrigin-RevId: 33bbefa169bc8ad4e6440e09d036e3b7ce11238e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a65872b29
commit
76ece48d63
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.java.indexing.JavaIndexingBundle;
|
||||
@@ -119,6 +119,11 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
public boolean shouldSearchInLanguage(@NotNull Language language) {
|
||||
return parameters.shouldSearchInLanguage(language);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassInheritorsSearch.SearchParameters getOriginalParameters() {
|
||||
return parameters;
|
||||
}
|
||||
})
|
||||
.allowParallelProcessing().forEach(subClass -> {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor<PsiMethod, O
|
||||
|
||||
Iterable<PsiMethod> cached = HighlightingCaches.getInstance(project).OVERRIDING_METHODS.get(method);
|
||||
if (cached == null) {
|
||||
cached = compute(method, project);
|
||||
cached = compute(method, parameters, project);
|
||||
// for non-physical elements ignore the cache completely because non-physical elements created so often/unpredictably so I can't figure out when to clear caches in this case
|
||||
if (ReadAction.compute(method::isPhysical)) {
|
||||
HighlightingCaches.getInstance(project).OVERRIDING_METHODS.put(method, cached);
|
||||
@@ -108,7 +108,7 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor<PsiMethod, O
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Iterable<PsiMethod> compute(@NotNull PsiMethod method, @NotNull Project project) {
|
||||
private static Iterable<PsiMethod> compute(@NotNull PsiMethod method, OverridingMethodsSearch.SearchParameters parameters, @NotNull Project project) {
|
||||
final PsiClass containingClass = ReadAction.compute(method::getContainingClass);
|
||||
assert containingClass != null;
|
||||
Collection<PsiMethod> result = new HashSet<>();
|
||||
@@ -124,11 +124,27 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor<PsiMethod, O
|
||||
|
||||
// use wider scope to handle public method defined in package-private class which is subclassed by public class in the same package which is subclassed by public class from another package with redefined method
|
||||
SearchScope allScope = GlobalSearchScope.allScope(project);
|
||||
boolean success = ClassInheritorsSearch.search(containingClass, allScope, true).allowParallelProcessing().forEach(inheritorsProcessor);
|
||||
boolean success = ClassInheritorsSearch.search(new ClassInheritanceSearchFromJavaOverridingMethodsParameters(containingClass, allScope, parameters))
|
||||
.allowParallelProcessing().forEach(inheritorsProcessor);
|
||||
assert success;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class ClassInheritanceSearchFromJavaOverridingMethodsParameters extends ClassInheritorsSearch.SearchParameters {
|
||||
private final OverridingMethodsSearch.SearchParameters myOriginalParameters;
|
||||
|
||||
public ClassInheritanceSearchFromJavaOverridingMethodsParameters(@NotNull PsiClass aClass,
|
||||
@NotNull SearchScope scope,
|
||||
OverridingMethodsSearch.SearchParameters parameters) {
|
||||
super(aClass, scope, true, true, true);
|
||||
myOriginalParameters = parameters;
|
||||
}
|
||||
|
||||
public OverridingMethodsSearch.SearchParameters getOriginalParameters() {
|
||||
return myOriginalParameters;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod findOverridingMethod(@NotNull PsiClass inheritor,
|
||||
@NotNull PsiMethod method,
|
||||
|
||||
Reference in New Issue
Block a user