Skip to content

Commit

Permalink
fix: check type before casting to PsiDocCommentOwner during hover
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Aug 11, 2023
1 parent afe404b commit 1581693
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.redhat.devtools.intellij.quarkus.javadoc;

import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMember;
import com.intellij.psi.javadoc.PsiDocComment;

Expand All @@ -20,10 +19,14 @@

public class JavadocContentAccess {
private static Reader getHTMLContentReader(PsiMember member, boolean allowInherited, boolean useAttachedJavadoc) {
PsiDocComment doc = ((PsiDocCommentOwner) member).getDocComment();
PsiElement sourceMember = member.getNavigationElement();
if (sourceMember instanceof PsiDocCommentOwner) {
doc = ((PsiDocCommentOwner) sourceMember).getDocComment();
PsiDocComment doc = null;
// Check the Javadoc of the current member
if (member instanceof PsiDocCommentOwner) {
doc = ((PsiDocCommentOwner) member).getDocComment();
}
// Check the Javadoc of the member it's inherited from
if (doc == null && allowInherited && member.getNavigationElement() instanceof PsiDocCommentOwner) {
doc = ((PsiDocCommentOwner) member.getNavigationElement()).getDocComment();
}
return doc == null ? null : new JavaDocCommentReader(doc.getText());
}
Expand Down

0 comments on commit 1581693

Please sign in to comment.