'Introduce local variable' vs 'Split into declaration and assignment'
Answered
list.add(instantiateRequest(jobName, resultSet));
With `ALT+ENTER` IntelliJ offers me the 'Introduce local variable' refactoring. But with this code, it refactors it to this:
boolean add = list.add(instantiateRequest(jobName, resultSet));
and if I hit `ALT+ENTER` again, it only offers me 'Split into declaration and assignment'.
What I really want as the result of refactoring is this though:
Thing job = instantiateRequest(jobName, resultSet);
list.add(job);
Maybe it's even possible but I don't know how. I have tried highlighting instantiateRequest(), or putting the cursor on it, but IntelliJ ignores it.
Please sign in to leave a comment.
Hello,
You may put the cursor somewhere inside the instantiateRequest:
Then use Cmd+Alt+V shortcut (or Refactor | Extract | Variable), you will be suggested two variants for extraction, select the first one:
The result of refactoring will be as follows: