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

Summary: Refactor Encapsulate fields formatting to match code style
Product: cnd Reporter: slip
Component: EditorAssignee: Alexander Simon <alexvsimon>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

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.