mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-200584 Goto symbol should allow to navigate to method overrides
This commit is contained in:
+9
-3
@@ -12,6 +12,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
@@ -55,7 +56,7 @@ public class DefaultSymbolNavigationContributor implements ChooseByNameContribut
|
||||
|
||||
List<PsiMember> result = new ArrayList<>();
|
||||
for (PsiMethod method : cache.getMethodsByName(name, scope)) {
|
||||
if (!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method, scope, qualifiedMatcher)) {
|
||||
if (!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method, scope, qualifiedMatcher, pattern)) {
|
||||
result.add(method);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +119,12 @@ public class DefaultSymbolNavigationContributor implements ChooseByNameContribut
|
||||
});
|
||||
|
||||
}
|
||||
private static boolean hasSuperMethod(final PsiMethod method, final GlobalSearchScope scope, final Condition<? super PsiMember> qualifiedMatcher) {
|
||||
|
||||
private static boolean hasSuperMethod(PsiMethod method, GlobalSearchScope scope, Condition<PsiMember> qualifiedMatcher, String pattern) {
|
||||
if (pattern.contains(".") && Registry.is("ide.goto.symbol.include.overrides.on.qualified.patterns")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasSuperMethodCandidates(method, scope, qualifiedMatcher)) {
|
||||
return false;
|
||||
}
|
||||
@@ -173,7 +179,7 @@ public class DefaultSymbolNavigationContributor implements ChooseByNameContribut
|
||||
Iterator<PsiMethod> iterator = collectedMethods.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
PsiMethod method = iterator.next();
|
||||
if (!hasSuperMethod(method, scope, qualifiedMatcher) && !processor.process(method)) return;
|
||||
if (!hasSuperMethod(method, scope, qualifiedMatcher, completePattern) && !processor.process(method)) return;
|
||||
ProgressManager.checkCanceled();
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
@@ -495,6 +495,13 @@ class Intf {
|
||||
assert gotoClass('java.Str*Builder', true) == [sb, asb]
|
||||
}
|
||||
|
||||
void "test include overridden qualified name method matches"() {
|
||||
def m1 = myFixture.addClass('interface HttpRequest { void start() {} }').methods[0]
|
||||
def m2 = myFixture.addClass('interface Request extends HttpRequest { void start() {} }').methods[0]
|
||||
assert gotoSymbol('Request.start') == [m1, m2]
|
||||
assert gotoSymbol('start') == [m1] // works as usual for non-qualified patterns
|
||||
}
|
||||
|
||||
private List<Object> gotoClass(String text, boolean checkboxState = false) {
|
||||
return getPopupElements(new GotoClassModel2(project), text, checkboxState)
|
||||
}
|
||||
|
||||
@@ -719,6 +719,9 @@ ide.goto.rebuild.delay.description=How many milliseconds to wait before updating
|
||||
ide.goto.file.include.directories=true
|
||||
ide.goto.file.include.directories.description=Whether to include directories in Goto File even when the entered pattern contains no slashes (otherwise they're included anyway)
|
||||
|
||||
ide.goto.symbol.include.overrides.on.qualified.patterns=true
|
||||
ide.goto.symbol.include.overrides.on.qualified.patterns.description=Disable deduplication of methods from the same hierarchy if qualified pattern is used in Goto Symbol
|
||||
|
||||
ide.structural.navigation.visit.fields=false
|
||||
ide.structural.navigation.visit.fields.description=Whether fields should be stopped at when navigating to the nex/previous structural member by Alt+Down/Up.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user