How get PsiMethod block comment?



I have a class with some methods in them.

I now want to find the block comment for the PsiMethod I found but it gives me null when I use method.getDocComment().

What do I have to do to extract the comment from the below method? 

I found the annotation(s), name etc.

* This is an example of a deprecated method
public boolean isDeprated() {
    return true;

Comment actions Permalink

PsiClass.accept(new JavaRecursiveElementVisitor(){....} can help.

Override the functions for the elements you want to detect.

Comment actions Permalink

I found a snippet of code doing the below, anything wrong with that (it seems to work)?


PsiDocComment currentComment = null;
PsiElement firstElement = internalMethod.getFirstChild();

if ( ( firstElement != null ) && ( firstElement instanceof PsiDocComment ) ) {
currentComment = ( PsiDocComment ) firstElement;

Please sign in to leave a comment.