Skip to content

Commit

Permalink
IDEA-151736 Cannot open link in javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
donnerpeter committed Feb 16, 2016
1 parent badfb92 commit 225876b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.intellij.pom.Navigatable;
import com.intellij.psi.*;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.awt.RelativePoint;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -137,10 +138,16 @@ private static void chooseAmbiguousTarget(final Editor editor, int offset, PsiEl

private static void gotoTargetElement(@NotNull PsiElement element, @NotNull Editor currentEditor, @NotNull PsiFile currentFile) {
if (element.getContainingFile() == currentFile) {
Project project = element.getProject();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
new OpenFileDescriptor(project, currentFile.getViewProvider().getVirtualFile(), element.getTextOffset()).navigateIn(currentEditor);
return;
int offset = element.getTextOffset();
PsiElement leaf = currentFile.findElementAt(offset);
// check that element is really physically inside the file
// there are fake elements with custom navigation (e.g. opening URL in browser) that override getContainingFile for various reasons
if (leaf != null && PsiTreeUtil.isAncestor(element, leaf, false)) {
Project project = element.getProject();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
new OpenFileDescriptor(project, currentFile.getViewProvider().getVirtualFile(), offset).navigateIn(currentEditor);
return;
}
}

Navigatable navigatable = element instanceof Navigatable ? (Navigatable)element : EditSourceUtil.getDescriptor(element);
Expand Down

0 comments on commit 225876b

Please sign in to comment.