mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
functional expressions: ensure that method to search is functional (not default or static)
This commit is contained in:
+1
-1
@@ -172,7 +172,7 @@ public final class MethodHierarchyTreeStructure extends HierarchyTreeStructure {
|
||||
descriptors.add(d);
|
||||
}
|
||||
|
||||
FunctionalExpressionSearch.search(psiClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
FunctionalExpressionSearch.search(getBaseMethod()).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
descriptors.add(new MethodHierarchyNodeDescriptor(myProject, descriptor, expression, false, MethodHierarchyTreeStructure.this));
|
||||
|
||||
+2
-5
@@ -77,11 +77,8 @@ class JavaChangeSignatureUsageSearcher {
|
||||
methods.add(method);
|
||||
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
final PsiClass containingClass = psiMethod.getContainingClass();
|
||||
if (psiMethod == LambdaUtil.getFunctionalInterfaceMethod(containingClass)) {
|
||||
for (PsiFunctionalExpression functionalExpression : FunctionalExpressionSearch.search(containingClass)) {
|
||||
result.add(new FunctionalInterfaceChangedUsageInfo(functionalExpression, psiMethod));
|
||||
}
|
||||
for (PsiFunctionalExpression functionalExpression : FunctionalExpressionSearch.search(psiMethod)) {
|
||||
result.add(new FunctionalInterfaceChangedUsageInfo(functionalExpression, psiMethod));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -485,15 +485,13 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
private static void findFunctionalExpressions(final List<UsageInfo> usages, PsiMethod... methods) {
|
||||
for (PsiMethod method : methods) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (LambdaUtil.getFunctionalInterfaceMethod(containingClass) == method) {
|
||||
FunctionalExpressionSearch.search(containingClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
usages.add(new SafeDeleteFunctionalExpressionUsageInfo(expression, containingClass));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
FunctionalExpressionSearch.search(method).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
usages.add(new SafeDeleteFunctionalExpressionUsageInfo(expression, containingClass));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -18,9 +18,12 @@ package com.intellij.psi.search.searches;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFunctionalExpression;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.EmptyQuery;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.QueryExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -53,6 +56,18 @@ public class FunctionalExpressionSearch extends ExtensibleQueryFactory<PsiFuncti
|
||||
return INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope));
|
||||
}
|
||||
|
||||
public static Query<PsiFunctionalExpression> search(final PsiMethod psiMethod) {
|
||||
return search(psiMethod, GlobalSearchScope.allScope(psiMethod.getProject()));
|
||||
}
|
||||
|
||||
public static Query<PsiFunctionalExpression> search(final PsiMethod psiMethod, SearchScope scope) {
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
return INSTANCE.createUniqueResultsQuery(new SearchParameters(psiMethod.getContainingClass(), scope));
|
||||
}
|
||||
|
||||
return EmptyQuery.getEmptyQuery();
|
||||
}
|
||||
|
||||
public static Query<PsiFunctionalExpression> search(final PsiClass aClass) {
|
||||
return search(aClass, GlobalSearchScope.allScope(aClass.getProject()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user