views:

57

answers:

2

How do I convert a local variable in a method to a method parameter using eclipse refactor?

+1  A: 

If you remove the declaration of your local variable, the places you used that variable will no longer compile. You can then choose "Add parameter" from the quick fix menu (Ctrl-1 I think, don't have Eclipse open now).

Jorn
Although it doesn't use the Eclipse refactor feature, this works just as well
chrisbunney
+5  A: 

You can use the "Introduce Parameter" option on the Refactor.. submenu when you right-click.

You'll need to select an expression, such as the expression used to initialise the local variable, for this to work.

chrisbunney