Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to put selected code in a separate function

Is there any tool/functionality in IntelliJ/Android Studio/... to put some selected code in a separate function (Like a function builder)?

I know it's a very lazy person question, but this tool could be useful sometimes.

like image 811
arodriguezdonaire Avatar asked Aug 09 '15 11:08

arodriguezdonaire


2 Answers

I believe what you are looking for is Extract method refactoring. You can access it via Refactor/Extract/Method menu or using a keyboard shortcut:

  • CTRL+ALT+M (Linux, Windows)
  • ++M (OS X)
like image 116
Bohuslav Burghardt Avatar answered Nov 24 '22 15:11

Bohuslav Burghardt


Select the code >> Right Click >> Refactor >> Extract >> Method :

enter image description here

like image 20
imansdn Avatar answered Nov 24 '22 16:11

imansdn