madhavd1/vscode-javadoc-tools

Issue generating JavaDoc for member variables

srihari-sridharan opened this issue · 11 comments

First, appreciations for your contribution to the community of developers.
Just a minor defect. Java doc is not getting associated with the member variables.

    private final AlertLevel alertLevel;
    private final String eventSource;
    private final Object payload;

    

/** 
 * @return AlertLevel
 */

/** 
 * @return String
 */

/** 
 * @return Object
 */

instead of

    /**
     * @return AlertLevel
     */
    private final AlertLevel alertLevel;

    /**
     * @return String
     */
    private final String eventSource;

    /**
     * @return Object
     */
    private final Object payload;

How did you get that? I think the extension only works at the moment for methods.
Btw, @madhavd1 thanks for your contribution :)

Thanks for the appreciation guys!
@cruizba is right that the extension only generates javadoc for methods. Ideally it shouldn't create comments for anything else. I'll check what the issue here is.

I'm still working on handling javadoc comments for other class symbols. Should have an update coming for that soon.

@srihari-sridharan, coincidentally my project for testing out this extension is also a Spring boot project with Lombok.
I just tried again and was not able to replicate this issue.

Would it be possible for you to provide the file where you are able to replicate it?

Hi @srihari-sridharan,
I'm still not able to replicate this.
The extension only picks up methods from all the DocumentSymbols by comparing with vscode.SymbolKind.Method.
It shouldn't be picking up member variables unless it is reading them as "methods" instead of "fields".

Can you please check if that's the case - In case your member variables are being falsely read as Methods, you will see the purple box next to them instead of blue.
image

Madhav

hello, I can confirm the issue, my setup is as follows:

vscode: 1.48.2
javadoc tools: 1.4.0
gabrielbb.vscode-lombok: 1.0.1 (this extension is for lombok)
I also have extensions for java/spring, if you still cannot replicate I can share my extension list.

I have a maven project with lombok (no spring): and i have a class like this:

@Getter
@Setter
@ToString
@EqualsAndHashCode(of = {"fecha", "evento", "usuario", "ip"})
@NoArgsConstructor
public class DataDTO implements Serializable {

  private static final long serialVersionUID = -4892590542766570450L;

  private Date fecha;
  private Integer evento;
  private String usuario;
  private String ip;

  public DataDTO(Date fecha, Integer evento, String usuario, String ip) {
    this();
    this.fecha = fecha;
    this.evento = evento;
    this.usuario = usuario;
    this.ip = ip;
  }

  public void addValidacionFallida(String msg) {
    evento = null;
  }
}

when I run "Generate javadoc for current file" I get:

/** 
 * @return Date
 */

/** 
 * @return Integer
 */

/** 
 * @return String
 */

/** 
 * @return String
 */
@Getter
@Setter

/** 
 * @return String
 */
@ToString

/** 
 * @return boolean
 */

/** 
 * @return boolean
 */

/** 
 * @return int
 */
@EqualsAndHashCode(of = {"fecha", "evento", "usuario", "ip"})
@NoArgsConstructor
public class DataDTO implements Serializable {

  private static final long serialVersionUID = -4892590542766570450L;

  private Date fecha;
  private Integer evento;
  private String usuario;
  private String ip;

  public DataDTO(Date fecha, Integer evento, String usuario, String ip) {
    this();
    this.fecha = fecha;
    this.evento = evento;
    this.usuario = usuario;
    this.ip = ip;
  }

  /**
   * @param msg
   */
  public void addValidacionFallida(String msg) {
    evento = null;
  }
}

If you see, above the @getter and @Setter annotations, javadoc blocks are generated as well as for @tostring and hashcode.

If I check the outline window, I can see all the generated methods (get*, set*, toString etc), maybe you don't have the lombok extension.

Thanks for your extension.

Hi @rz-itac ,
Thanks for the details. I'm looking into this.

Hi @rz-itac, @srihari-sridharan
I was able to replicate the issue now.
I'm working on fixing the issue. Will let you know once the fix is available.

Madhav

Fixed with 1e508e1