Is it possible in Intellij (surround with method?!/refactoring)?

Hi Intellij Community.
I am pretty bad at searching internet for this functionallity I will describe. I would like to ask if this is possible in intellij?
Let's say I have line

myVar.getId();

and I would like to transform it to

myMethod(myVar.getId());

Also is it possible to do something like

myMethod(myVar.getId());

and if I put my carret after "my" in "myMethod" and would let codeCompletion suggest me "myAnotherMethod" and by some magic shortcut it would end in

myAnotherMethod(myVar.getId());

??

Thank you

PS: I hope I made it clear what I am looking for :)

2 comments
Comment actions Permalink

What is the use case? Why do you need to do it so often?

Did you try the surround live template? https://www.jetbrains.com/idea/help/simple-parameterized-and-surround-live-templates.html#d690724e173

0
Comment actions Permalink

Well to be honest I dont know right now some specific use case, but it was mostly required during some refactorings and it happend to me so often that I had to ask here :).
Fortunately I find out method how to satisfy my first use case. Simple ctrl+shift+enter (Complete Current Statement).

Thanks anyway

0

Please sign in to leave a comment.