mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Added Python modules to 'Navigate to class' and 'Navigate to symbol' results (PY-6923)
This commit is contained in:
@@ -19,11 +19,14 @@ import com.intellij.navigation.ChooseByNameContributor;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.jetbrains.python.psi.stubs.PyClassNameIndex;
|
||||
import com.jetbrains.python.psi.stubs.PyModuleNameIndex;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -31,13 +34,18 @@ import java.util.Collection;
|
||||
public class PyGotoClassContributor implements ChooseByNameContributor {
|
||||
@NotNull
|
||||
public String[] getNames(final Project project, final boolean includeNonProjectItems) {
|
||||
final Collection<String> classNames = PyClassNameIndex.allKeys(project);
|
||||
return ArrayUtil.toStringArray(classNames);
|
||||
Set<String> results = new HashSet<String>();
|
||||
results.addAll(PyClassNameIndex.allKeys(project));
|
||||
results.addAll(PyModuleNameIndex.getAllKeys(project));
|
||||
return ArrayUtil.toStringArray(results);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NavigationItem[] getItemsByName(final String name, final String pattern, final Project project, final boolean includeNonProjectItems) {
|
||||
final Collection<PyClass> classes = PyClassNameIndex.find(name, project, includeNonProjectItems);
|
||||
return classes.toArray(new NavigationItem[classes.size()]);
|
||||
public NavigationItem[] getItemsByName(final String name, final String pattern, final Project project,
|
||||
final boolean includeNonProjectItems) {
|
||||
final List<NavigationItem> results = new ArrayList<NavigationItem>();
|
||||
results.addAll(PyClassNameIndex.find(name, project, includeNonProjectItems));
|
||||
results.addAll(PyModuleNameIndex.find(name, project, includeNonProjectItems));
|
||||
return results.toArray(new NavigationItem[results.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.jetbrains.python.psi.PyQualifiedNameOwner;
|
||||
import com.jetbrains.python.psi.search.PyProjectScopeBuilder;
|
||||
import com.jetbrains.python.psi.stubs.PyClassNameIndex;
|
||||
import com.jetbrains.python.psi.stubs.PyFunctionNameIndex;
|
||||
import com.jetbrains.python.psi.stubs.PyModuleNameIndex;
|
||||
import com.jetbrains.python.psi.stubs.PyVariableNameIndex;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -41,6 +42,7 @@ public class PyGotoSymbolContributor implements GotoClassContributor {
|
||||
public String[] getNames(final Project project, final boolean includeNonProjectItems) {
|
||||
Set<String> symbols = new HashSet<String>();
|
||||
symbols.addAll(PyClassNameIndex.allKeys(project));
|
||||
symbols.addAll(PyModuleNameIndex.getAllKeys(project));
|
||||
symbols.addAll(StubIndex.getInstance().getAllKeys(PyFunctionNameIndex.KEY, project));
|
||||
symbols.addAll(StubIndex.getInstance().getAllKeys(PyVariableNameIndex.KEY, project));
|
||||
return ArrayUtil.toStringArray(symbols);
|
||||
@@ -54,6 +56,7 @@ public class PyGotoSymbolContributor implements GotoClassContributor {
|
||||
|
||||
List<NavigationItem> symbols = new ArrayList<NavigationItem>();
|
||||
symbols.addAll(PyClassNameIndex.find(name, project, scope));
|
||||
symbols.addAll(PyModuleNameIndex.find(name, project, includeNonProjectItems));
|
||||
symbols.addAll(PyFunctionNameIndex.find(name, project, scope));
|
||||
symbols.addAll(PyVariableNameIndex.find(name, project, scope));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user