deamon
deamon

Reputation: 92509

NetBeans "inline variable" refactoring

Is it possible to inline (and the other way around) variables with a NetBeans refactoring?

Something like this:

Something s = new Something();
render(s);

should become

render(new Something());

The ReSharper equivalent is Ctrl+R+I.

Upvotes: 2

Views: 4372

Answers (1)

Jonathan Spooner
Jonathan Spooner

Reputation: 7752

It seems that this functionality has been requested and subsequently integrated into 7.1. The RFE in question is Bug 57545 - Inline Method/Variable Refactoring and according to comment #17 has been integrated into main_golden.

Also according to comment #19 this feature will be included in version 7.1 which is in Beta now (download here) and according to the roadmap is due to be released on Dec 14, 2011

Edit

I downloaded NetBeans 7.1 Beta and successfully refactored your example into your requirement. To do this, I placed my cursor on the s of Something s = new Something(); and from the context menu (right click) I selected Inline.... This brought up this warning:

Inline refactor warning

After clicking Preview you get the following diff:

Inline refactor diff view

After clicking on the Do Refactoring button, the refactor is complete.

Upvotes: 4

Related Questions