Search in sources :

Example 1 with NavigationItem

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()]);
}
Also used : Call(org.elixir_lang.psi.call.Call) AtUnqualifiedNoParenthesesCall(org.elixir_lang.psi.AtUnqualifiedNoParenthesesCall) NavigationItem(com.intellij.navigation.NavigationItem) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) HashMap(java.util.HashMap) NamedElement(org.elixir_lang.psi.NamedElement) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NavigationItem

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()]);
}
Also used : NavigationItem(com.intellij.navigation.NavigationItem) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NavigationItem

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()]);
}
Also used : GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) NavigationItem(com.intellij.navigation.NavigationItem) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ArrayList(java.util.ArrayList) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) GrAnnotationMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with NavigationItem

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;
}
Also used : NavigationItem(com.intellij.navigation.NavigationItem) KtClass(org.jetbrains.kotlin.psi.KtClass) KtStringTemplateExpression(org.jetbrains.kotlin.psi.KtStringTemplateExpression) ItemPresentation(com.intellij.navigation.ItemPresentation) KtObjectDeclaration(org.jetbrains.kotlin.psi.KtObjectDeclaration)

Example 5 with NavigationItem

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();
}
Also used : NavigationItem(com.intellij.navigation.NavigationItem)

Aggregations

NavigationItem (com.intellij.navigation.NavigationItem)25 ItemPresentation (com.intellij.navigation.ItemPresentation)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 NotNull (org.jetbrains.annotations.NotNull)6 PsiFile (com.intellij.psi.PsiFile)5 PsiElementNavigationItem (com.intellij.navigation.PsiElementNavigationItem)4 PsiElement (com.intellij.psi.PsiElement)4 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)4 ArrayList (java.util.ArrayList)4 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)3 Project (com.intellij.openapi.project.Project)3 ChooseByNameContributor (com.intellij.navigation.ChooseByNameContributor)2 Logger (com.intellij.openapi.diagnostic.Logger)2 com.intellij.psi (com.intellij.psi)2 HintManager (com.intellij.codeInsight.hint.HintManager)1 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 NoDataException (com.intellij.debugger.NoDataException)1 SourcePosition (com.intellij.debugger.SourcePosition)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 PositionManagerImpl (com.intellij.debugger.engine.PositionManagerImpl)1