Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: Is there a way to list all interfaces implemented by a class and its parents?

I work on a relatively complex Java project where classes commonly have four or five ancestors before Object. Given such a class, e.g. D in a hierarchy like this: Object > A > B > C > D, I would like to know what all interfaces it effectively implements. That is, I am also interested in seeing that D implements, say, Serializable even if that is declared only in the declaration of class B and even when D does not actually implement any of the methods specified by the interface (naturally, if talking about Serializable).

Some potential sources of this information I tried include:

  • using "Group by Defining Type" in the Structure window -- but that won't show empty interfaces (= interfaces without methods), and
  • the "Hierarchy" window -- but that does not include interfaces when viewing the hierarchy for a class.

Is there a way to obtain this information in IDEA without having to open files of all ancestor classes of the class in question?

like image 652
mkorvas Avatar asked Feb 21 '17 20:02

mkorvas


People also ask

How do I find all implemented classes for an interface in Java IntelliJ?

Place the caret at a symbol in the editor or select the symbol in the Structure tool window. Press Ctrl+F12 or choose Navigate | Implementation(s) from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.

How do I find class hierarchy in IntelliJ?

Select the desired class in the Project tool window or open it in the editor. From the main menu, select Navigate | Type Hierarchy or just press Ctrl+H .

How can I see all class methods in IntelliJ?

By default, IntelliJ IDEA shows all classes, methods, and other elements of the current file. To toggle the elements you want to show, click the corresponding buttons on the Structure tool window toolbar. to show class fields. to have protected class members shown in the tree.

How do I open the implementation of interface method in IntelliJ?

To navigate to the implementation, press Ctrl+Alt+B .


2 Answers

You can try

  • Open the class file.
  • Press Ctrl + H. (or just navigate through project window and press the keys.)
  • You can see the Hierarchy Diagram appears right hand side.
  • Try switch to Supertypes Hierarchy(circled in red in below image) button. :))

enter image description here

like image 189
Supun Wijerathne Avatar answered Sep 28 '22 18:09

Supun Wijerathne


If you are fine with UML representation, then use

Press ⌥⇧⌘U or ⌥⌘U on mac

Press Ctrl+Shift+Alt+U or Ctrl+Alt+U on default windows keymap

See https://www.jetbrains.com/help/idea/2016.3/viewing-class-hierarchy-as-a-class-diagram.html

like image 21
Martin Linha Avatar answered Sep 28 '22 20:09

Martin Linha