Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check type before casting to PsiDocCommentOwner during hover #1103

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading