简体   繁体   English

IntelliJ IDEA:有没有办法列出一个类及其父类实现的所有接口?

[英]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 . 我从事一个相对复杂的Java项目,其中类通常在Object之前有四个或五个祖先。 Given such a class, eg D in a hierarchy like this: Object > A > B > C > D , I would like to know what all interfaces it effectively implements. 给定这样一个类,例如像这样的层次结构中的DObject > A > B > C > D ,我想知道它有效实现的所有接口。 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 ). 也就是说,我也有兴趣看到D实现了Serializable即使它只在B类声明中声明,即使D实际上没有实现接口指定的任何方法(当然,如果谈论的话) 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 在Structure窗口中使用“Group by Defining Type” - 但不会显示空接口(=没有方法的接口),以及
  • 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? 有没有办法在IDEA中获取此信息而无需打开相关类的所有祖先类的文件?

You can try 你可以试试

  • Open the class file. 打开类文件。
  • Press Ctrl + H . 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. 尝试切换到超类型层次结构 (在下图中以红色圈出)按钮。 :)) :))

在此输入图像描述

If you are fine with UML representation, then use 如果您对UML表示没问题,那么请使用

Press ⌥⇧⌘U or ⌥⌘U on mac 在mac上按⌥⇧⌘U⌥⌘U

Press Ctrl+Shift+Alt+U or Ctrl+Alt+U on default windows keymap 在默认的Windows键盘映射上按Ctrl+Shift+Alt+UCtrl+Alt+U

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 IntelliJ IDEA 中显示一个类的所有父类和子类? - How to show all parents and subclasses of a class in IntelliJ IDEA? 如何从intellij中的类中分辨出所有已实现的接口和超类? - How to tell all implemented interfaces and superclasses from a class in intellij? 有没有办法在IntelliJ IDEA中编译所有JSP文件? - Is there a way to compile all JSP files in IntelliJ IDEA? 有没有办法在 Intellij Idea 中用另一个类替换类? - Is there a way to replace class by another one in Intellij Idea? IntelliJ IDEA:处理项目及其依赖项的最佳方法 - IntelliJ IDEA: Best way to work on a project and on its dependency 在android studio / IntelliJ IDEA中使用标记接口 - Using marker interfaces in android studio / IntelliJ IDEA 有没有办法通过IntelliJ IDEA中的方法查看所有路径? - Is there a way to view all the paths through a method in IntelliJ IDEA? 有什么方法可以自动将“此”关键字添加到Intellij Idea中的类字段吗? - Is there any way to add “this” key word automatically to class fields in Intellij Idea? 在Intellij Idea中自动将所有匿名内部类替换为lambda - Automatic replacing all anonymous inner class to lambda in Intellij Idea 如何在IntelliJ IDEA中未经测试列出所有类? - How to list all classes without test in IntelliJ IDEA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM