How to show all parents and subclasses of a class

2019-01-21 08:49发布

When I'm editing a Java class in Eclipse, when my cursor is over a class variable, I can do Ctrl+T to have a popup that shows all its parents and subclasses. What is the equivalent in IntelliJ?

Example:

Use|r user = new User();

The pipe is my cursor.

13条回答
混吃等死
2楼-- · 2019-01-21 09:09

Ctrl+U - go to base class

Ctrl+Alt+B - got to implementation. Type parts of class name to narrow down the list

Ctrl+H - open type hierarchy tool window

Ctrl+Alt+U - peek class/interface inheritance hierarchy

查看更多
小情绪 Triste *
3楼-- · 2019-01-21 09:11

With Eclipse, hitting Ctrl+T on a type displays its subtypes and hit again Ctrl+T displays so supertypes. And so for... this is a toggle.
That is really helpful and also very straight.

Unfortunately with IntelliJ, the switch between the supertypes and the subtypes doesn't have any default shortcut. So you will have to click on the icons of the hierarchy windows.
If like me you favor the keyboard shortcuts to the "move cursor and click on mouse" option, I encourage you to set a binding for these two operations. For example Ctrl+Down for subtypes and Ctrl+Up for supertypes.

Where you can change the binding ("Bas" means "Down" and "Haut" means "Up") : biding

Note that these bindings are contextual to the "Other" context (Eclipse does have a similar enough concept). 1) In this way, enter Ctrl+T on a ArrayList type produces :

Default hierarchy

2) Enter Ctrl+Down focuses on subtypes :

subtypes focus

3) And Enter Ctrl+Up focuses on supertypes :

supertypes focus

In this way, I find it better than the default behavior but to be honest even with that shortcut adding, the IntelliJ feature is not as good as Eclipse which the Ctrl+T shortcut also works on methods...

查看更多
看我几分像从前
4楼-- · 2019-01-21 09:15

For Mac users who come here, this is the shortcut for IntelliJ 14.1.4:

+H by default.

查看更多
叛逆
5楼-- · 2019-01-21 09:16

Also try CTRL+SHIFT+A in case of any doubt. The short cut for short cut information.

查看更多
叼着烟拽天下
6楼-- · 2019-01-21 09:16

For Mac Users, the shortcut is

control + h

查看更多
淡お忘
7楼-- · 2019-01-21 09:17

Navigate | Type Hierarchy Ctrl+H will show similar information, however in the Panel. You can Float and Unpin the Panel so that it appears on the fixed display position only when you use the keyboard shortcut.

查看更多
登录 后发表回答