inline method: search all overriding methods

GitOrigin-RevId: 2c561e3a4a86bf6eedb69f2177ca310b2d8b1590
This commit is contained in:
Anna Kozlova
2020-07-24 07:51:48 +00:00
committed by intellij-monorepo-bot
parent d462bc773f
commit 36761cbb63
4 changed files with 27 additions and 2 deletions
@@ -147,8 +147,14 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
usages.add(new UsageInfo(reference.getElement()));
}
OverridingMethodsSearch.search(myMethod, myRefactoringScope, false).forEach(method -> {
usages.add(new UsageInfo(method));
OverridingMethodsSearch.search(myMethod, myRefactoringScope, true).forEach(method -> {
for (HierarchicalMethodSignature signature : method.getHierarchicalMethodSignature().getSuperSignatures()) {
if (signature.getMethod() == myMethod) {
usages.add(new UsageInfo(method));
return true;
}
}
return true;
});
@@ -45,6 +45,9 @@ public final class OverridingMethodsSearch extends ExtensibleQueryFactory<PsiMet
super(EP_NAME);
}
/**
* @param checkDeep false means that processing would be stopped after the first found item
*/
@NotNull
public static Query<PsiMethod> search(@NotNull PsiMethod method, @NotNull SearchScope scope, final boolean checkDeep) {
if (ReadAction.compute(() -> !PsiUtil.canBeOverridden(method))) return EmptyQuery.getEmptyQuery(); // Optimization
@@ -14,4 +14,13 @@ class B extends A {
class C extends B {
@Override
void foo() {}
}
class B1 extends A {
@Override
void foo() {}
void err() {
super.foo();
}
}
@@ -11,4 +11,11 @@ class B extends A {
class C extends B {
@Override
void foo() {}
}
class B1 extends A {
void foo() {}
void err() {
}
}