Supun Wijerathne Supun Wijerathne - 1 year ago 82
Java Question

Is there a way to change method parameter list intellij?

To be generalized, Let's take an example like this.

I have a method something like this.

public void mymethod(int param1, String param2){
//do something

And I want to change it into something like this.

public void mymethod(int param1, String param2, String param3){
//do something

Is there a preferred way to do that with intellij without breaking usages?

Answer Source

You can do the followings with intellij.

With Refactor -> Change Signature menu, you can:

  • Change the method name, return type and visibility scope.
  • Add new parameters and remove the existing ones. Note that you can also add a parameter using a dedicated Extract Parameter refactoring.
  • Reorder parameters.
  • Change parameter names and types.
  • Add and remove exceptions.
  • Propagate new parameters and exceptions through the method call hierarchy.

To go to Refactor -> Change Signature menu

In the editor, place the cursor within the name of the method whose signature you want to change. Do one of the following:

  • Press Ctrl+F6.
  • Choose Refactor | Change Signature in the main menu.
  • Select Refactor | Change Signature from the context menu (right-click).

For more, please have a look at here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download