com.intellij.navigation.NavigationItem Java Examples
The following examples show how to use
com.intellij.navigation.NavigationItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GotoBaseAction.java From CppTools with Apache License 2.0 | 6 votes |
protected void gotoActionPerformed(AnActionEvent anActionEvent) { final Project project = (Project) anActionEvent.getDataContext().getData(DataConstants.PROJECT); final ChooseByNamePopup byNamePopup = ChooseByNamePopup.createPopup( project, new MyContributorsBasedGotoByModel(project, getNameContributor()), (PsiElement)null ); byNamePopup.invoke(new ChooseByNamePopupComponent.Callback() { public void elementChosen(Object element) { ((NavigationItem)element).navigate(true); } public void onClose() { if (GotoBaseAction.this.getClass().equals(myInAction)) myInAction = null; } }, ModalityState.current(), false); }
Example #2
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static String doGenerateInfo(@Nonnull PsiElement element) { if (element instanceof PsiFile) { final VirtualFile virtualFile = ((PsiFile)element).getVirtualFile(); if (virtualFile != null) { return virtualFile.getPresentableUrl(); } } String info = getQuickNavigateInfo(element); if (info != null) { return info; } if (element instanceof NavigationItem) { final ItemPresentation presentation = ((NavigationItem)element).getPresentation(); if (presentation != null) { return presentation.getPresentableText(); } } return null; }
Example #3
Source File: TreeState.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static String calcId(@Nullable Object userObject) { if (userObject == null) return ""; Object value = userObject instanceof NodeDescriptorProvidingKey ? ((NodeDescriptorProvidingKey)userObject).getKey() : userObject instanceof AbstractTreeNode ? ((AbstractTreeNode)userObject).getValue() : userObject; if (value instanceof NavigationItem) { try { String name = ((NavigationItem)value).getName(); return name != null ? name : StringUtil.notNullize(value.toString()); } catch (Exception ignored) { } } return StringUtil.notNullize(userObject.toString()); }
Example #4
Source File: DefaultFileNavigationContributor.java From consulo with Apache License 2.0 | 6 votes |
@Override public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> _processor, @Nonnull FindSymbolParameters parameters) { final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries(); final Processor<PsiFileSystemItem> processor = item -> { if (!globalSearch && ProjectCoreUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) { return true; } return _processor.process(item); }; boolean directoriesOnly = isDirectoryOnlyPattern(parameters); if (!directoriesOnly) { FilenameIndex.processFilesByName(name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter()); } if (directoriesOnly || Registry.is("ide.goto.file.include.directories")) { FilenameIndex.processFilesByName(name, true, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter()); } }
Example #5
Source File: GotoSymbolModel2.java From consulo with Apache License 2.0 | 6 votes |
@Override public String getFullName(final Object element) { for(ChooseByNameContributor c: getContributors()) { if (c instanceof GotoClassContributor) { String result = ((GotoClassContributor) c).getQualifiedName((NavigationItem) element); if (result != null) return result; } } if (element instanceof PsiElement) { final PsiElement psiElement = (PsiElement)element; final String containerText = SymbolPresentationUtil.getSymbolContainerText(psiElement); return containerText + "." + getElementName(element); } return getElementName(element); }
Example #6
Source File: GotoImplementationHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nonnull protected String getChooserTitle(@Nonnull PsiElement sourceElement, String name, int length, boolean finished) { ItemPresentation presentation = ((NavigationItem)sourceElement).getPresentation(); String fullName; if (presentation == null) { fullName = name; } else { PsiElement container = getContainer(sourceElement); ItemPresentation containerPresentation = container == null || container instanceof PsiFile ? null : ((NavigationItem)container).getPresentation(); String containerText = containerPresentation == null ? null : containerPresentation.getPresentableText(); fullName = (containerText == null ? "" : containerText+".") + presentation.getPresentableText(); } return CodeInsightBundle.message("goto.implementation.chooserTitle", fullName, length, finished ? "" : " so far"); }
Example #7
Source File: ServiceSymbolContributor.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String serviceName, String s2, Project project, boolean b) { if(!Symfony2ProjectComponent.isEnabled(project)) { return new NavigationItem[0]; } List<NavigationItem> navigationItems = new ArrayList<>(); for(PsiElement psiElement: ServiceIndexUtil.findServiceDefinitions(project, serviceName)) { if(psiElement instanceof NavigationItem) { navigationItems.add(new NavigationItemEx(psiElement, serviceName, Symfony2Icons.SERVICE, "Service")); } } return navigationItems.toArray(new NavigationItem[navigationItems.size()]); }
Example #8
Source File: CSharpSymbolNameContributor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Override public void processElementsWithName( @Nonnull String name, @Nonnull Processor<NavigationItem> navigationItemProcessor, @Nonnull FindSymbolParameters findSymbolParameters) { Project project = findSymbolParameters.getProject(); IdFilter idFilter = findSymbolParameters.getIdFilter(); GlobalSearchScope searchScope = findSymbolParameters.getSearchScope(); StubIndex.getInstance().processElements(CSharpIndexKeys.METHOD_INDEX, name, project, searchScope, idFilter, DotNetLikeMethodDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.EVENT_INDEX, name, project, searchScope, idFilter, DotNetEventDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.PROPERTY_INDEX, name, project, searchScope, idFilter, DotNetPropertyDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.FIELD_INDEX, name, project, searchScope, idFilter, DotNetFieldDeclaration.class, (Processor) navigationItemProcessor); }
Example #9
Source File: SymfonyCommandSymbolContributor.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String name, String s2, Project project, boolean b) { if(!Symfony2ProjectComponent.isEnabled(project)) { return new NavigationItem[0]; } List<NavigationItem> navigationItems = new ArrayList<>(); for (SymfonyCommand symfonyCommand : SymfonyCommandUtil.getCommands(project)) { if(symfonyCommand.getName().equals(name)) { navigationItems.add(new NavigationItemEx(symfonyCommand.getPsiElement(), name, Symfony2Icons.SYMFONY, "Command")); } } return navigationItems.toArray(new NavigationItem[navigationItems.size()]); }
Example #10
Source File: SymbolPresentationUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static String getSymbolContainerText(PsiElement element) { if (element instanceof NavigationItem) { final ItemPresentation presentation = ((NavigationItem)element).getPresentation(); if (presentation != null){ return presentation.getLocationString(); } else { PsiFile file = element.getContainingFile(); if (file != null) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) return virtualFile.getPath(); } } } return null; }
Example #11
Source File: GotoFileModel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected boolean acceptItem(final NavigationItem item) { if (item instanceof PsiFile) { final PsiFile file = (PsiFile)item; final Collection<FileType> types = getFilterItems(); // if language substitutors are used, PsiFile.getFileType() can be different from // PsiFile.getVirtualFile().getFileType() if (types != null) { if (types.contains(file.getFileType())) return true; VirtualFile vFile = file.getVirtualFile(); return vFile != null && types.contains(vFile.getFileType()); } return true; } else { return super.acceptItem(item); } }
Example #12
Source File: CSharpSymbolNameContributor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nonnull @Override public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) { Collection<? extends PsiElement> k1 = MethodIndex.getInstance().get(name, project, GlobalSearchScope.allScope(project)); Collection<? extends PsiElement> k2 = EventIndex.getInstance().get(name, project, GlobalSearchScope.allScope(project)); Collection<? extends PsiElement> k3 = PropertyIndex.getInstance().get(name, project, GlobalSearchScope.allScope(project)); Collection<? extends PsiElement> k4 = FieldIndex.getInstance().get(name, project, GlobalSearchScope.allScope(project)); List<PsiElement> list = new ArrayList<PsiElement>(k1.size() + k2.size() + k3.size() + k4.size()); list.addAll(k1); list.addAll(k2); list.addAll(k3); list.addAll(k4); return list.toArray(new NavigationItem[list.size()]); }
Example #13
Source File: GotoClassModel2.java From consulo with Apache License 2.0 | 5 votes |
@Override public String getFullName(final Object element) { if (element instanceof PsiElement && !((PsiElement)element).isValid()) { return null; } for (ChooseByNameContributor c : getContributors()) { if (c instanceof GotoClassContributor) { String result = ((GotoClassContributor)c).getQualifiedName((NavigationItem)element); if (result != null) return result; } } return getElementName(element); }
Example #14
Source File: CSharpBaseGroupingRule.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @Override public FileStatus getFileStatus() { T element = myPointer.getElement(); if(element == null) { return null; } return NavigationItemFileStatus.get((NavigationItem) element); }
Example #15
Source File: GoToClassContributor.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
@Nullable @Override public String getQualifiedName(final NavigationItem item) { if (item instanceof ProtoType) { return getQualifiedNameUserType((ProtoType) item); } return null; }
Example #16
Source File: ORModuleContributor.java From reasonml-idea-plugin with MIT License | 5 votes |
@Nullable @Override public String getQualifiedName(NavigationItem item) { if (item instanceof FileBase) { return ((FileBase) item).getModuleName(); } else if (item instanceof PsiQualifiedElement) { return ((PsiQualifiedElement) item).getQualifiedName(); } return null; }
Example #17
Source File: ORModuleContributor.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void processElementsWithName(@NotNull String name, @NotNull Processor<? super NavigationItem> processor, @NotNull FindSymbolParameters parameters) { Project project = parameters.getProject(); GlobalSearchScope scope = parameters.getSearchScope(); for (PsiModule psiModule : PsiFinder.getInstance(project).findModulesbyName(name, ORFileType.both, null, scope)) { processor.process(psiModule); } }
Example #18
Source File: ChooseTargetContributor.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 5 votes |
@Override public NavigationItem[] getItemsByName( String name, String pattern, Project project, boolean includeNonProjectItems) { String alias = null; int index = name.lastIndexOf(ALIAS_SEPARATOR); if (index > 0) { alias = name.substring(index + ALIAS_SEPARATOR.length()); name = name.substring(0, index); } return new NavigationItem[] { new ChooseTargetItem(name, alias) }; }
Example #19
Source File: FilteringGotoByModel.java From consulo with Apache License 2.0 | 5 votes |
@Override protected boolean acceptItem(final NavigationItem item) { T filterValue = filterValueFor(item); if (filterValue != null) { final Collection<T> types = getFilterItems(); return types == null || types.contains(filterValue); } return true; }
Example #20
Source File: GotoClassAction.java From consulo with Apache License 2.0 | 5 votes |
static void handleSubMemberNavigation(ChooseByNamePopup popup, Object element) { if (element instanceof PsiElement && ((PsiElement)element).isValid()) { PsiElement psiElement = getElement(((PsiElement)element), popup); psiElement = psiElement.getNavigationElement(); VirtualFile file = PsiUtilCore.getVirtualFile(psiElement); if (file != null && popup.getLinePosition() != -1) { OpenFileDescriptor descriptor = new OpenFileDescriptor(psiElement.getProject(), file, popup.getLinePosition(), popup.getColumnPosition()); Navigatable n = descriptor.setUseCurrentWindow(popup.isOpenInCurrentWindowRequested()); if (n.canNavigate()) { n.navigate(true); return; } } if (file != null && popup.getMemberPattern() != null) { NavigationUtil.activateFileWithPsiElement(psiElement, !popup.isOpenInCurrentWindowRequested()); Navigatable member = findMember(popup.getMemberPattern(), popup.getTrimmedText(), psiElement, file); if (member != null) { member.navigate(true); } } NavigationUtil.activateFileWithPsiElement(psiElement, !popup.isOpenInCurrentWindowRequested()); } else { EditSourceUtil.navigate(((NavigationItem)element), true, popup.isOpenInCurrentWindowRequested()); } }
Example #21
Source File: SymbolPresentationUtil.java From consulo with Apache License 2.0 | 5 votes |
public static String getSymbolPresentableText(@Nonnull PsiElement element) { if (element instanceof NavigationItem) { final ItemPresentation presentation = ((NavigationItem)element).getPresentation(); if (presentation != null){ return presentation.getPresentableText(); } } if (element instanceof PsiNamedElement) return ((PsiNamedElement)element).getName(); return element.getText(); }
Example #22
Source File: HaxeSymbolContributor.java From intellij-haxe with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(@NotNull final String name, @NotNull final String pattern, @NotNull final Project project, final boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); final Collection<HaxeComponentName> result = HaxeSymbolIndex.getItemsByName(name, project, scope); return result.toArray(new NavigationItem[result.size()]); }
Example #23
Source File: HaxeClassContributor.java From intellij-haxe with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); final Collection<HaxeComponent> result = HaxeComponentIndex.getItemsByName(name, project, scope); return result.toArray(new NavigationItem[result.size()]); }
Example #24
Source File: DefaultUsageTargetProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public UsageTarget[] getTargets(PsiElement psiElement) { if (psiElement instanceof NavigationItem) { if (FindManager.getInstance(psiElement.getProject()).canFindUsages(psiElement)) { return new UsageTarget[]{new PsiElement2UsageTargetAdapter(psiElement)}; } } return null; }
Example #25
Source File: TemplateFileContributor.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String templateName, String s2, Project project, boolean b) { if(!Symfony2ProjectComponent.isEnabled(project)) { return new NavigationItem[0]; } return TwigUtil.getTemplatePsiElements(project, templateName) .stream() .map(psiFile -> new NavigationItemEx(psiFile, templateName, TwigIcons.TwigFileIcon, "Template", false) ) .toArray(NavigationItemEx[]::new); }
Example #26
Source File: BaseCppSymbolContributor.java From CppTools with Apache License 2.0 | 5 votes |
public NavigationItem[] getItemsByName(String string, final Project project, boolean b) { if (string.length() == 0 || !Communicator.getInstance(project).isServerUpAndRunning() ) { return EMPTY_NAVIGATION_ITEMS; } PerProjectData data = myProject2Symbols.get(project); if (data == null || !(data.mySymbols.contains(string))) return EMPTY_NAVIGATION_ITEMS; final FindSymbolsCommand symbolsCommand = new FindSymbolsCommand(string, myType); symbolsCommand.post(project); final int usageCount = symbolsCommand.getUsageCount(); if (usageCount > 0) { NavigationItem[] items = new NavigationItem[usageCount]; int i = 0; for(final FileUsage fu:symbolsCommand.getUsagesList().files) { for(final OurUsage u:fu.usageList) { items[i++] = createNavigatationItem(u, string, fu, project); } } return items; } else { return EMPTY_NAVIGATION_ITEMS; } }
Example #27
Source File: ChooseTargetContributor.java From buck with Apache License 2.0 | 5 votes |
@Override public NavigationItem[] getItemsByName( String name, String pattern, Project project, boolean includeNonProjectItems) { String alias = null; int index = name.lastIndexOf(ALIAS_SEPARATOR); if (index > 0) { alias = name.substring(index + ALIAS_SEPARATOR.length()); name = name.substring(0, index); } return new NavigationItem[] {new ChooseTargetItem(name, alias)}; }
Example #28
Source File: ThriftSymbolContributor.java From intellij-thrift with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { List<ThriftDeclaration> declarations = ThriftSubDeclarationIndex.findDeclaration(null, name, project, getScope(project, includeNonProjectItems)); return declarations.toArray(new NavigationItem[declarations.size()]); }
Example #29
Source File: CoverageListNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public void navigate(boolean requestFocus) { if (canNavigate()) { final PsiNamedElement value = (PsiNamedElement)getValue(); if (requestFocus) { NavigationUtil.activateFileWithPsiElement(value, true); } else if (value instanceof NavigationItem) { ((NavigationItem)value).navigate(requestFocus); } } }
Example #30
Source File: UsageViewImpl.java From consulo with Apache License 2.0 | 5 votes |
private static ConfigurableUsageTarget getConfigurableTarget(@Nonnull UsageTarget[] targets) { ConfigurableUsageTarget configurableUsageTarget = null; if (targets.length != 0) { NavigationItem target = targets[0]; if (target instanceof ConfigurableUsageTarget) { configurableUsageTarget = (ConfigurableUsageTarget)target; } } return configurableUsageTarget; }