mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[anna] unify single- and multi- target navigation
This commit is contained in:
+10
-15
@@ -92,17 +92,8 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
PsiElement navElement = element.getNavigationElement();
|
||||
navElement = TargetElementUtilBase.getInstance().getGotoDeclarationTarget(element, navElement);
|
||||
|
||||
if (navElement instanceof Navigatable) {
|
||||
if (((Navigatable)navElement).canNavigate()) {
|
||||
((Navigatable)navElement).navigate(true);
|
||||
}
|
||||
}
|
||||
else if (navElement != null) {
|
||||
int navOffset = navElement.getTextOffset();
|
||||
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(navElement);
|
||||
if (virtualFile != null) {
|
||||
new OpenFileDescriptor(project, virtualFile, navOffset).navigate(true);
|
||||
}
|
||||
if (navElement != null) {
|
||||
gotoTargetElement(navElement);
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
@@ -114,10 +105,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
PsiElementProcessor<PsiElement> navigateProcessor = new PsiElementProcessor<PsiElement>() {
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element) {
|
||||
Navigatable navigatable = EditSourceUtil.getDescriptor(element);
|
||||
if (navigatable != null && navigatable.canNavigate()) {
|
||||
navigatable.navigate(true);
|
||||
}
|
||||
gotoTargetElement(element);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -128,6 +116,13 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
}
|
||||
}
|
||||
|
||||
private static void gotoTargetElement(PsiElement element) {
|
||||
Navigatable navigatable = element instanceof Navigatable ? (Navigatable)element : EditSourceUtil.getDescriptor(element);
|
||||
if (navigatable != null && navigatable.canNavigate()) {
|
||||
navigatable.navigate(true);
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if processor is run or is going to be run after showing popup
|
||||
public static boolean chooseAmbiguousTarget(@NotNull Editor editor,
|
||||
int offset,
|
||||
|
||||
Reference in New Issue
Block a user