Does IntelliJ IDEA for Java have a refactor function that can automatically move a variable definition from within a block to outside a block and refactor the definition inside the block to be a reference.
In short, turn this:
try {
IndexResponse indexResponse = elkService.post(pipelineModel);
}
Into this:
IndexResponse indexResponse = null;
try {
indexResponse = elkService.post(pipelineModel);
}
I find myself doing this quite frequently. The "surround by" refactors are smart about this in that if do NOT yet have the surrounding element (try/catch, if/then, etc.) and the code you want to surround defines variables that are used outside the surround-bound code, it will define the variable outside the block.
What I'm trying to do is refactor code where I INTRODUCE a reference outside an already-existing block.
Not the end of the world, to do this manually, but I was wondering if such a thing exists and/or if others wished for it.
