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 268994 - Refactor Encapsulate fields formatting to match code style
Summary: Refactor Encapsulate fields formatting to match code style
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Alexander Simon
Depends on:
Reported: 2016-11-16 00:57 UTC by slip
Modified: 2016-11-16 11:09 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description slip 2016-11-16 00:57:18 UTC
Running the encapsulate fields option requires a bit of extra work to make the generated code adhere to our coding style.

For example:

class A
	int mVariable;

Would generate:

void A::SetMVariable(int mVariable)
	this->mVariable = mVariable;

int A::GetMVariable()
	return mVariable;

The desired result is:

void A::SetVariable(int variable)
	mVariable = variable;

int A::GetVariable()
	return mVariable;

I understand that the dialog box allows you to modify the names so the methods aren't named "MVariable" but the work involved in modifying each field in the dialog box (especially for a large number of members) is a lot of extra work, which kind of defeats the point of such a tool.

1. It would be nice if you could configure the default behaviour of the dialog, or at least detect naming prefixes such as the one above.
2. An option to select whether or not to use "this->" in the setter would also be good. If the prefix cannot be detected automatically to remove then the parameter could be given an extra character, for example "_variable" or "iVariable". Common prefixes are "m" or "m_" for member classes.

Ideally the behaviour could be configured so the settings do not need to be changed each time.