use of com.intellij.navigation.NavigationItem in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsByName.
/*
* Instance Methods
*/
/**
* Returns the list of navigation items matching the specified name.
*
* @param name the name selected from the list.
* @param pattern the original pattern entered in the dialog
* @param project the project in which the navigation is performed.
* @param includeNonProjectItems if true, the navigation items for non-project items (for example,
* library classes) should be included in the returned array.
* @return the array of navigation items.
*/
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = globalSearchScope(project, includeNonProjectItems);
Collection<NamedElement> result = StubIndex.getElements(AllName.KEY, name, project, scope, NamedElement.class);
List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size());
EnclosingModularByCall enclosingModularByCall = new EnclosingModularByCall();
Map<CallDefinition.Tuple, CallDefinition> callDefinitionByTuple = new HashMap<CallDefinition.Tuple, CallDefinition>();
for (final NamedElement element : result) {
// Use navigation element so that source element is used for compiled elements
PsiElement sourceElement = element.getNavigationElement();
if (sourceElement instanceof Call) {
getItemsByNameFromCall(name, items, enclosingModularByCall, callDefinitionByTuple, (Call) sourceElement);
}
}
return items.toArray(new NavigationItem[items.size()]);
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class PyGotoSymbolContributor method getItemsByName.
@NotNull
public NavigationItem[] getItemsByName(final String name, final String pattern, final Project project, final boolean includeNonProjectItems) {
final GlobalSearchScope scope = includeNonProjectItems ? PyProjectScopeBuilder.excludeSdkTestsScope(project) : GlobalSearchScope.projectScope(project);
List<NavigationItem> symbols = new ArrayList<>();
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));
return symbols.toArray(new NavigationItem[symbols.size()]);
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class GroovyGoToSymbolContributor method getItemsByName.
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
List<NavigationItem> symbols = new ArrayList<>();
symbols.addAll(StubIndex.getElements(GrFieldNameIndex.KEY, name, project, scope, GrField.class));
symbols.addAll(StubIndex.getElements(GrMethodNameIndex.KEY, name, project, scope, GrMethod.class));
symbols.addAll(StubIndex.getElements(GrAnnotationMethodNameIndex.KEY, name, project, scope, GrAnnotationMethod.class));
return symbols.toArray(new NavigationItem[symbols.size()]);
}
use of com.intellij.navigation.NavigationItem in project kotlin by JetBrains.
the class ReferenceUtils method renderAsGotoImplementation.
public static String renderAsGotoImplementation(@NotNull PsiElement element) {
PsiElement navigationElement = element.getNavigationElement();
if (navigationElement instanceof KtObjectDeclaration && ((KtObjectDeclaration) navigationElement).isCompanion()) {
//default presenter return null for companion object
KtClass containingClass = PsiTreeUtil.getParentOfType(navigationElement, KtClass.class);
assert containingClass != null;
return "companion object of " + renderAsGotoImplementation(containingClass);
}
if (navigationElement instanceof KtStringTemplateExpression) {
return KtPsiUtilKt.getPlainContent((KtStringTemplateExpression) navigationElement);
}
Assert.assertTrue(navigationElement instanceof NavigationItem);
ItemPresentation presentation = ((NavigationItem) navigationElement).getPresentation();
if (presentation == null) {
String elementText = element.getText();
return elementText != null ? elementText : navigationElement.getText();
}
String presentableText = presentation.getPresentableText();
String locationString = presentation.getLocationString();
if (locationString == null && element.getParent() instanceof PsiAnonymousClass) {
locationString = "<anonymous>";
}
return locationString == null || navigationElement instanceof PsiPackage ? // for PsiPackage, presentableText is FQ name of current package
presentableText : locationString + "." + presentableText;
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class FindUsagesManager method showSettingsAndFindUsages.
public static void showSettingsAndFindUsages(@NotNull NavigationItem[] targets) {
if (targets.length == 0)
return;
NavigationItem target = targets[0];
if (!(target instanceof ConfigurableUsageTarget))
return;
((ConfigurableUsageTarget) target).showSettings();
}
Aggregations