Java Code Examples for com.intellij.pom.Navigatable#navigate()
The following examples show how to use
com.intellij.pom.Navigatable#navigate() .
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: AbstractGotoSEContributor.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean processSelectedItem(@Nonnull Object selected, int modifiers, @Nonnull String searchText) { if (selected instanceof PsiElement) { if (!((PsiElement)selected).isValid()) { LOG.warn("Cannot navigate to invalid PsiElement"); return true; } PsiElement psiElement = preparePsi((PsiElement)selected, modifiers, searchText); Navigatable extNavigatable = createExtendedNavigatable(psiElement, searchText, modifiers); if (extNavigatable != null && extNavigatable.canNavigate()) { extNavigatable.navigate(true); return true; } NavigationUtil.activateFileWithPsiElement(psiElement, openInCurrentWindow(modifiers)); } else { EditSourceUtil.navigate(((NavigationItem)selected), true, openInCurrentWindow(modifiers)); } return true; }
Example 2
Source File: NavBarPanel.java From consulo with Apache License 2.0 | 6 votes |
protected void doubleClick(final Object object) { if (object instanceof Navigatable) { Navigatable navigatable = (Navigatable)object; if (navigatable.canNavigate()) { navigatable.navigate(true); } } else if (object instanceof Module) { ProjectView projectView = ProjectView.getInstance(myProject); AbstractProjectViewPane projectViewPane = projectView.getProjectViewPaneById(projectView.getCurrentViewId()); if (projectViewPane != null) { projectViewPane.selectModule((Module)object, true); } } else if (object instanceof Project) { return; } hideHint(true); }
Example 3
Source File: OccurenceNavigatorActionBase.java From consulo with Apache License 2.0 | 6 votes |
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; OccurenceNavigator navigator = getNavigator(e.getDataContext()); if (navigator == null) { return; } if (!hasOccurenceToGo(navigator)) { return; } OccurenceNavigator.OccurenceInfo occurenceInfo = go(navigator); if (occurenceInfo == null) { return; } Navigatable descriptor = occurenceInfo.getNavigateable(); if (descriptor != null && descriptor.canNavigate()) { descriptor.navigate(false); } if(occurenceInfo.getOccurenceNumber()==-1||occurenceInfo.getOccurencesCount()==-1){ return; } WindowManager.getInstance().getStatusBar(project).setInfo( IdeBundle.message("message.occurrence.N.of.M", occurenceInfo.getOccurenceNumber(), occurenceInfo.getOccurencesCount())); }
Example 4
Source File: JumpToSourceAction.java From MavenHelper with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { final Navigatable navigatable = getNavigatable(myArtifact, myProject, myMavenProject); if (navigatable != null && navigatable.canNavigate()) { navigatable.navigate(true); } else { final Notification notification = new Notification(MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Parent dependency not found, strange...", NotificationType.WARNING); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, myProject); } }); } }
Example 5
Source File: GoToBuckFile.java From buck with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); if (project == null) { return; } VirtualFile buckFile = findBuckFile(project); if (buckFile != null) { final OpenFileDescriptor descriptor = new OpenFileDescriptor(e.getProject(), buckFile); // This is for better cursor position. final Navigatable n = descriptor.setUseCurrentWindow(false); if (!n.canNavigate()) { return; } n.navigate(true); } }
Example 6
Source File: UsageViewImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static Navigatable getNavigatableForNode(@Nonnull DefaultMutableTreeNode node, boolean allowRequestFocus) { Object userObject = node.getUserObject(); if (userObject instanceof Navigatable) { final Navigatable navigatable = (Navigatable)userObject; return navigatable.canNavigate() ? new Navigatable() { @Override public void navigate(boolean requestFocus) { navigatable.navigate(allowRequestFocus && requestFocus); } @Override public boolean canNavigate() { return navigatable.canNavigate(); } @Override public boolean canNavigateToSource() { return navigatable.canNavigateToSource(); } } : null; } return null; }
Example 7
Source File: StructureViewElementWrapper.java From consulo with Apache License 2.0 | 5 votes |
@Override public void navigate(final boolean requestFocus) { Navigatable navigatable = getNavigatableInTemplateLanguageFile(); if (navigatable != null) { navigatable.navigate(requestFocus); } }
Example 8
Source File: XBreakpointItem.java From consulo with Apache License 2.0 | 5 votes |
@Override public void navigate(boolean requestFocus) { Navigatable navigatable = myBreakpoint.getNavigatable(); if (navigatable != null && navigatable.canNavigate()) { navigatable.navigate(requestFocus); } }
Example 9
Source File: NewErrorTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
private void navigateToSource(final boolean focusEditor) { NavigatableMessageElement element = getSelectedMessageElement(); if (element == null) { return; } final Navigatable navigatable = element.getNavigatable(); if (navigatable.canNavigate()) { navigatable.navigate(focusEditor); } }
Example 10
Source File: OpenSourceUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void navigate(final boolean requestFocus, final boolean tryNotToScroll, final Navigatable...navigatables) { if (navigatables == null) return; for (Navigatable navigatable : navigatables) { if (navigatable.canNavigate()) { if (tryNotToScroll && navigatable instanceof StatePreservingNavigatable) { ((StatePreservingNavigatable)navigatable).navigate(requestFocus, true); } else { navigatable.navigate(requestFocus); } } } }
Example 11
Source File: OpenSourceUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void navigate(final boolean requestFocus, final Navigatable...navigatables) { if (navigatables == null) return; for (Navigatable navigatable : navigatables) { if (navigatable.canNavigate()) { navigatable.navigate(requestFocus); } } }
Example 12
Source File: OpenInEditorAction.java From consulo with Apache License 2.0 | 5 votes |
public void openEditor(@Nonnull Project project, @Nonnull Navigatable[] navigatables) { boolean success = false; for (Navigatable navigatable : navigatables) { if (navigatable.canNavigate()) { navigatable.navigate(true); success = true; } } if (success && myAfterRunnable != null) myAfterRunnable.run(); }
Example 13
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 14
Source File: GotoTestOrCodeHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void navigateToElement(@Nonnull Navigatable element) { if (element instanceof PsiElement) { NavigationUtil.activateFileWithPsiElement((PsiElement)element, true); } else { element.navigate(true); } }
Example 15
Source File: IssueOutputFilter.java From intellij with Apache License 2.0 | 5 votes |
@Nullable private static HyperlinkInfo getHyperlinkInfo(IssueOutput issue) { Navigatable navigatable = issue.getNavigatable(); if (navigatable != null) { return project -> navigatable.navigate(true); } VirtualFile vf = resolveVirtualFile(issue.getFile()); return vf != null ? project -> new OpenFileDescriptor(project, vf, issue.getLine() - 1, issue.getColumn() - 1) .navigate(true) : null; }
Example 16
Source File: IdeHelper.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public static void navigateToPsiElement(@NotNull PsiElement psiElement) { final Navigatable descriptor = PsiNavigationSupport.getInstance().getDescriptor(psiElement); if (descriptor != null) { descriptor.navigate(true); } }
Example 17
Source File: MsilElementWrapper.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override @RequiredUIAccess public void navigate(boolean requestFocus) { final Class<? extends PsiElement> navigationElementClass = getNavigationElementClass(); Consumer<PsiFile> consumer = navigationElementClass == null ? MsilRepresentationNavigateUtil.DEFAULT_NAVIGATOR : new Consumer<PsiFile>() { @Override public void consume(PsiFile file) { final Ref<Navigatable> navigatableRef = Ref.create(); file.accept(new PsiRecursiveElementWalkingVisitor() { @Override @RequiredReadAction public void visitElement(PsiElement element) { MsilElementWrapper<T> msilWrapper = MsilElementWrapper.this; if(navigationElementClass.isAssignableFrom(element.getClass()) && isEquivalentTo(element, msilWrapper)) { PsiElement elementParent = element.getParent(); PsiElement wrapperParent = msilWrapper.getParent(); // check if parent type is equal to self type if(elementParent instanceof CSharpTypeDeclaration && wrapperParent instanceof CSharpTypeDeclaration) { if(!CSharpElementCompareUtil.isEqual(elementParent, wrapperParent, myOriginal)) { return; } } navigatableRef.set((Navigatable) element); stopWalking(); return; } super.visitElement(element); } }); Navigatable navigatable = navigatableRef.get(); if(navigatable != null) { navigatable.navigate(true); } file.navigate(true); } }; MsilRepresentationNavigateUtil.navigateToRepresentation(myOriginal, CSharpFileType.INSTANCE, consumer); }
Example 18
Source File: CompositePsiElement.java From consulo with Apache License 2.0 | 4 votes |
@Override public void navigate(boolean requestFocus) { Navigatable descriptor = PsiNavigationSupport.getInstance().getDescriptor(this); if (descriptor != null) descriptor.navigate(requestFocus); }
Example 19
Source File: GotoTargetHandler.java From consulo with Apache License 2.0 | 4 votes |
protected void navigateToElement(@Nonnull Navigatable descriptor) { descriptor.navigate(true); }
Example 20
Source File: GotoDeclarationAction.java From consulo with Apache License 2.0 | 4 votes |
private static void gotoTargetElement(PsiElement element) { Navigatable navigatable = element instanceof Navigatable ? (Navigatable)element : EditSourceUtil.getDescriptor(element); if (navigatable != null && navigatable.canNavigate()) { navigatable.navigate(true); } }