I am trying to use the getDocComment method to grab some javadoc from a variable declaration, however when there is an annotation between the comment and element then getDocComment returns null
For example:
/**
* A description of varA
*/
private SomeObject varA;
Then I get my output correctly as: * `varA` (`SomeObject`) - A description of varA
However, if I have an annotation on the variable it does not get the description (debugger shows null).
/**
* A description of varA
*/
@NotNull
private SomeObject varA;
Then I get my output incorrectly as: * `varA` (`SomeObject`) -
Just want to add some additional context as to why I suspect it is the annotation that is breaking this. The documentation for getDocComment() is as follows:
Returns the text of the documentation ("Javadoc") comment of an element.
A documentation comment of an element is a comment that begins with "/**", ends with a separate "*/", and immediately precedes the element, ignoring white space. Therefore, a documentation comment contains at least three "*" characters. The text returned for the documentation comment is a processed form of the comment as it appears in source code. The leading "/**" and trailing "*/" are removed. For lines of the comment starting after the initial "/**", leading white space characters are discarded as are any consecutive "*" characters appearing after the white space or starting the line. The processed lines are then concatenated together (including line terminators) and returned.
Is there a way around this or an alternate method I'm not seeing?