[英]How to identify all classes implementing a specific interface that do NOT extend some base class?
I have some interface Action
, and most of the classes implementing that interface are derived from some base AbstractAction
. 我有一些Action
接口,而实现该接口的大多数类都是从一些基本AbstractAction
派生的。 But I assume there are some classes that implement that interface, but that do not extend that base class. 但是我假设有一些实现该接口的类,但是并没有扩展该基类。
Is there a way using IntelliJ to identify such classes? 有没有办法使用IntelliJ来识别此类? (ideally: using the community edition) (理想情况下:使用社区版)
Edit: this is not a duplicate of How to show all parents and subclasses of a class in IntelliJ IDEA? 编辑:这不是如何在IntelliJ IDEA中显示类的所有父级和子类的重复项? , as I am looking to combine a condition like "implements X and NOT extends Y". ,因为我希望结合“实施X而不能扩展Y”这样的条件。
Works only in Intellij IDEA Ultimate Edition : 仅在Intellij IDEA Ultimate Edition中工作 :
The only thing that comes into my mind to sort of solve your problem directly with Intellij IDEA is to generate the uml class diagramm of your Action
interface. 我想直接使用Intellij IDEA直接解决您的问题的唯一想法就是生成Action
接口的uml类图 。
This lets you search visually for hierarchy patterns. 这使您可以直观地搜索层次结构模式。
Here is a diagramm for the JTextComponent
as an example: 这是一个JTextComponent
的图表作为示例:
Another approach - Using the right tool for the job 另一种方法-使用正确的工具完成工作
jqassistant is a tool that analyses your java code and its relations and stores that into a neo4j database. jqassistant是一个工具,可以分析Java代码及其关系并将其存储到neo4j数据库中。 This enables you to describe your problem as graph query with cypher . 这使您可以将问题描述为使用cypher的图形查询。
The easiest way to get started is to 最简单的入门方法是
./bin/jqassistant.sh scan -f your_application.jar
, then 运行./bin/jqassistant.sh scan -f your_application.jar
,然后 ./bin/jqassistant.sh server
通过./bin/jqassistant.sh server
启动./bin/jqassistant.sh server
Example: The query for finding all classes implementing aInteface
would look like 示例:查找所有实现aInteface
类的查询看起来像
MATCH (i:Interface {name:"aIntefaces"} )<-[:IMPLEMENTS]- (c) RETURN i,c
A query to your problem would look like: 对您的问题的查询如下所示:
MATCH
(i:Interface {name:'Action'} )<-[:IMPLEMENTS|EXTENDS*1..10]- (class),
(abstractAction:Class {name:'AbstractAction'})
where not (class)-->(abstractAction)
RETURN class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.