This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250784 - Insert Code: JavaDoc and generation of events and collection accessors
Summary: Insert Code: JavaDoc and generation of events and collection accessors
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P4 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-28 16:04 UTC by Stardust
Modified: 2015-02-28 16:04 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stardust 2015-02-28 16:04:16 UTC
These are improvement suggestions for the editor's code generator found in Context Menu > Insert Code...

1) JavaDoc generation
  A "Generate Javadoc" checkbox can be added to the generator's dialogs. With this option on, a short Javadoc is generated along with the code, containing a universal description of trivial methods.

  Example:
    | 
    | /**
    |  * Changes the width.
    |  *
    |  * @param width New width
    |  */
    | public void setWidth(int width) {
    |     this.width = width;
    | }
    |

  In the example, a setter for the 'width' property of a fictional class was generated. The name of the property was simply plugged into the Javadoc comment at different places. Trivial accessors can be described with a simple, universal description, which can be modified by the user to match a project's conventions.

----------------------------------------

2) Code generation for event listeners
  An "Introduce event" item could be added to the "Insert code..." menu. This feature would let the user generate code for handling certain types of event. The code generator would create the appropriate "addXListener()", "removeXListener()", "fireX()" methods.

----------------------------------------

3) Special accessors for collections
  If a class has a Collection member such as this:
    | List<...> items;
  Trying to generate Getters and Setters for this property would create methods of this kind:
    | public List<...> getItems() {
    |     return items;
    | }
    |
    | public void setItems(List<> items) {
    |     this.items = items;
    | }
  Having a class containing a collection of other objects is a common scenario, however it is rarely acceptable to leak a reference to the collection object, or to allow the user to replace it with another arbitrary object.
  The generator could instead create code for common dictionary operations (addItem(), removeItem(), findItem()). The name for these methods can be generated by removing the trailing 's' from the property's name if it has any. This scheme should fit most cases of property names.