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 112010 - Getter / setter generation should recognize members with _
Summary: Getter / setter generation should recognize members with _
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-06 03:02 UTC by _ markroth8
Modified: 2013-09-02 14:21 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 _ markroth8 2007-08-06 03:02:46 UTC
Some Java developers use the convention of prefixing member variables with underscore (_) when they are private to avoid
having to type "this.", also eliminating many possible coding errors due to namespace scoping issues. I'd like NetBeans
to recognize this fairly common convention (or at least have an option to recognize it).

More specifically, if I define a class similar to:

public class Foo {
    private int _bar;
}

When I generate getters and setters for _bar, I want them to look as follows:

public int getBar() {
    return _bar;
}

public void setBar(int bar) {
    _bar = bar;
}

NetBeans 5 used to have the ability to do this (though it did so inconsistently depending on which of the many
getter/setter generation options you chose).

In the current Alt+Insert feature in NetBeans 6, the getter and setter that is generated generates code like:

public int get_bar() {
    return this._bar;
}

public void set_bar(int _bar) {
    this._bar = _bar;
}

which is not the desired result.
Comment 1 steve_taylor 2008-01-30 00:28:38 UTC
At work I'm forced to prefix members with m_ and statics with s_. It would save a hell of a lot of my time if I could
configure NB6 with this convention so that automatically generated getters, setters and constructors adhere to it.
Comment 2 cyrill 2008-03-29 06:57:44 UTC
We prefix member variables with "m" and parameters with "p". Code will look like this:

private String mName;


public viod setName(final String pName) {
    mName = pName;
}

Specifically in longer methods/classes it is of great value if you know exactly from where the variable is deriving from.