Search in sources :

Example 21 with NavigationItem

use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.

the class Bookmark method getQualifiedName.

public String getQualifiedName() {
    String presentableUrl = myFile.getPresentableUrl();
    if (myFile.isDirectory())
        return presentableUrl;
    final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile);
    if (psiFile == null)
        return presentableUrl;
    StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile);
    if (builder instanceof TreeBasedStructureViewBuilder) {
        StructureViewModel model = ((TreeBasedStructureViewBuilder) builder).createStructureViewModel(null);
        Object element;
        try {
            element = model.getCurrentEditorElement();
        } finally {
            model.dispose();
        }
        if (element instanceof NavigationItem) {
            ItemPresentation presentation = ((NavigationItem) element).getPresentation();
            if (presentation != null) {
                presentableUrl = ((NavigationItem) element).getName() + " " + presentation.getLocationString();
            }
        }
    }
    return IdeBundle.message("bookmark.file.X.line.Y", presentableUrl, getLine() + 1);
}
Also used : LanguageStructureViewBuilder(com.intellij.lang.LanguageStructureViewBuilder) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) NavigationItem(com.intellij.navigation.NavigationItem) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) ItemPresentation(com.intellij.navigation.ItemPresentation) PsiFile(com.intellij.psi.PsiFile)

Example 22 with NavigationItem

use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.

the class GotoSymbolAction method gotoActionPerformed.

@Override
public void gotoActionPerformed(AnActionEvent e) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.symbol");
    Project project = e.getProject();
    if (project == null)
        return;
    GotoSymbolModel2 model = new GotoSymbolModel2(project);
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    showNavigationPopup(e, model, new GotoActionCallback<Language>() {

        @Override
        protected ChooseByNameFilter<Language> createFilter(@NotNull ChooseByNamePopup popup) {
            return new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project);
        }

        @Override
        public void elementChosen(ChooseByNamePopup popup, Object element) {
            EditSourceUtil.navigate((NavigationItem) element, true, popup.isOpenInCurrentWindowRequested());
        }
    }, "Symbols matching patterns", true);
}
Also used : Project(com.intellij.openapi.project.Project) NavigationItem(com.intellij.navigation.NavigationItem) Language(com.intellij.lang.Language)

Example 23 with NavigationItem

use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.

the class RelaxSymbolIndex method getSymbolsByName.

public static NavigationItem[] getSymbolsByName(final String name, Project project, boolean includeNonProjectItems) {
    final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
    final Collection<NavigationItem> result = new ArrayList<>();
    PsiManager psiManager = PsiManager.getInstance(project);
    for (VirtualFile file : FileBasedIndex.getInstance().getContainingFiles(NAME, name, scope)) {
        final PsiFile psiFile = psiManager.findFile(file);
        if (psiFile instanceof XmlFile) {
            final Grammar grammar = GrammarFactory.getGrammar((XmlFile) psiFile);
            if (grammar != null) {
                grammar.acceptChildren(new CommonElement.Visitor() {

                    @Override
                    public void visitDefine(Define define) {
                        if (name.equals(define.getName())) {
                            final PsiElement psi = define.getPsiElement();
                            if (psi != null) {
                                MyNavigationItem.add((NavigationItem) define.getPsiElement(), result);
                            }
                        }
                    }
                });
            }
        }
    }
    return result.toArray(new NavigationItem[result.size()]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) PsiManager(com.intellij.psi.PsiManager) Grammar(org.intellij.plugins.relaxNG.model.Grammar) CommonElement(org.intellij.plugins.relaxNG.model.CommonElement) NavigationItem(com.intellij.navigation.NavigationItem) PsiElementNavigationItem(com.intellij.navigation.PsiElementNavigationItem) Define(org.intellij.plugins.relaxNG.model.Define) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement)

Example 24 with NavigationItem

use of com.intellij.navigation.NavigationItem in project intellij-elixir by KronicDeth.

the class GotoSymbolContributorTest method testIssue472.

/*
     * Tests
     */
public void testIssue472() {
    myFixture.configureByFile("issue_472.ex");
    ChooseByNameContributor[] symbolModelContributors = ChooseByNameRegistry.getInstance().getSymbolModelContributors();
    GotoSymbolContributor gotoSymbolContributor = null;
    for (ChooseByNameContributor symbolModelContributor : symbolModelContributors) {
        if (symbolModelContributor instanceof GotoSymbolContributor) {
            gotoSymbolContributor = (GotoSymbolContributor) symbolModelContributor;
        }
    }
    assertNotNull(gotoSymbolContributor);
    NavigationItem[] itemsByName = gotoSymbolContributor.getItemsByName("decode_auth_type", "decode_a", myFixture.getProject(), false);
    assertEquals(2, itemsByName.length);
    assertInstanceOf(itemsByName[0], CallDefinition.class);
    CallDefinition callDefinition = (CallDefinition) itemsByName[0];
    assertEquals("decode_auth_type", callDefinition.name());
    assertInstanceOf(itemsByName[1], CallDefinitionClause.class);
    CallDefinitionClause callDefinitionClause = (CallDefinitionClause) itemsByName[1];
    assertEquals("decode_auth_type", callDefinitionClause.getName());
}
Also used : NavigationItem(com.intellij.navigation.NavigationItem) CallDefinition(org.elixir_lang.structure_view.element.CallDefinition) ChooseByNameContributor(com.intellij.navigation.ChooseByNameContributor) CallDefinitionClause(org.elixir_lang.structure_view.element.CallDefinitionClause)

Example 25 with NavigationItem

use of com.intellij.navigation.NavigationItem in project intellij-plugins by JetBrains.

the class GoToActionSymbolProvider method addItems.

protected void addItems(@NotNull final Module module, final String name, final List<NavigationItem> result) {
    final StrutsModel strutsModel = StrutsManager.getInstance(module.getProject()).getCombinedModel(module);
    if (strutsModel == null) {
        return;
    }
    final List<Action> actions = strutsModel.findActionsByName(name, null);
    for (final Action action : actions) {
        final NavigationItem item = createNavigationItem(action.getXmlTag(), action.getName().getStringValue() + " [" + action.getNamespace() + "]", Struts2Icons.Action);
        result.add(item);
    }
}
Also used : Action(com.intellij.struts2.dom.struts.action.Action) NavigationItem(com.intellij.navigation.NavigationItem) StrutsModel(com.intellij.struts2.dom.struts.model.StrutsModel)

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