Bug 541651

Summary: [hovering] Use field to show Javadoc for undocumented getter/setter
Product: [Eclipse Project] JDT Reporter: Steffen Brüntjen <steffen>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert
Version: 4.10Keywords: helpwanted
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Steffen Brüntjen CLA 2018-11-28 12:06:28 EST
While the Eclipse Javadoc popup on private members, their getters and their setters is extremely helpful, it's very reasonable to not add documentation in three places. That is so, because copying documentation is an additional expenditure itself and changes would have to be applied in all these places. So here's what I'd like to propose. Let's say we have this class:


class Human {

    /** Name of the human */
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}


When showing the Javadoc popup for one of the getters or setters, Eclipse could  show the original object member documentation in the case there's no existing documentation on the method.

One easy solution, albeit not the best one would be to implicitly add this Javadoc:


For getters:

/**
 * @return {@link #name}
 */


For setters:

/**
 * @param name {@link #name}
 */


This is an almost static replacement for empty Javadoc. The only dynamic part here is #name. A more sophisticated solution would be to show the complete original Javadoc.
Comment 1 Dani Megert CLA 2018-11-29 06:18:35 EST
Hint: When generating getters and setters you can also choose to add the comments.
Comment 2 Steffen Brüntjen CLA 2018-11-29 07:55:59 EST
Yep, I know that, but
  - changes would have to be applied in all these places and
  - that's boilerplate code which makes classes larger

Thanks!