Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Idea - Extract Class

Is possible in Intellij Idea 14 do something like in Eclipse: Refactor : Extract Class? Or I should do it manually?

Not found proper option in menu, and I am startled option is not available.

like image 557
xorgx3 Avatar asked Nov 24 '14 14:11

xorgx3


People also ask

How do I extract a class in IntelliJ?

Select a code fragment that you want to extract into a class. Depending on what you want to extract, from the main menu, select one of the following: Refactor | Extract | Delegate.

How do you extract a class?

Press Ctrl+Shift+R and then choose Extract Class. Right-click and choose Refactor | Extract Class from the context menu.

How do I extract files in IntelliJ?

To extract method:Press Ctrl+Alt+M or from the main menu, select Refactor | Extract | Method. In the dialog that opens, configure a method options, such as visibility, parameters, and so on. You can also change a name of the method if you need. Click OK.

What is happening when you extract a superclass?

The Extract Superclass refactoring lets you create a superclass for an existing class or rename the original class, so that it becomes an implementation for the newly created superclass.


1 Answers

Anything that's worth doing in eclipse can be done faster and easier in IntelliJ, but if you're used to eclipse then you'll have to work a little bit to understand IntelliJ's way of doing things.

If you place your cursor somewhere in the java code in question (or on the class name in the project window), the Refactor menu will have an Extract option. Extract Delegate, Interface, and Superclass are the three options that deal directly with classes. These menu options aren't available if your cursor isn't in java class code.

The Interface option extracts an interface, renames your class and makes it implement the interface. The 'Superclass' option extracts a superclass and changes references to refer to it rather than your, now, derived class. The Delegate option simply extracts the methods and properties you choose into a new class.

like image 82
Software Engineer Avatar answered Nov 08 '22 16:11

Software Engineer