From 267665ce7afbd67069e27f31d2e7c7c9b740634e Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Thu, 10 Aug 2023 19:52:46 +0200 Subject: [PATCH] fix: check type before casting to PsiDocCommentOwner during hover Signed-off-by: Fred Bricon --- .../quarkus/javadoc/JavadocContentAccess.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/javadoc/JavadocContentAccess.java b/src/main/java/com/redhat/devtools/intellij/quarkus/javadoc/JavadocContentAccess.java index 074822cde..2b1fdcbd0 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/javadoc/JavadocContentAccess.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/javadoc/JavadocContentAccess.java @@ -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; @@ -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()); }