如何识别实现不扩展某些基类的特定接口的所有类? [英] How to identify all classes implementing a specific interface that do NOT extend some base class?
问题描述
我有一些接口 Action
,大多数实现该接口的类都是从某些基本的 AbstractAction
派生的.但是我假设有一些实现该接口的类,但是并没有扩展该基类.
是否可以使用IntelliJ识别此类?(理想情况下:使用社区版)
这不是
另一种方法-使用正确的工具完成工作
jqassistant 是一种工具,可以分析您的Java代码及其关系并将其存储到neo4j中数据库.这使您可以使用密码将图形描述为图形查询.
最简单的入门方法是
- 下载二进制发行版 jqassistant
- 运行
./bin/jqassistant.sh scan -f your_application.jar
,然后 - 通过
./bin/jqassistant.sh服务器
启动服务器 - 并打开 http://localhost:7474/browser/
示例:查找所有实现 aInteface
的类的查询看起来像
MATCH(i:Interface {name:"aIntefaces"})<-[:IMPLEMENTS]-(c)返回i,c
对您的问题的查询如下:
MATCH(i:Interface {name:'Action'})<-[:: IMPLEMENTS | EXTENDS * 1..10]-(类),(abstractAction:Class {name:'AbstractAction'})哪里不是(class)->(abstractAction)RETURN类
I have some interface Action
, and most of the classes implementing that interface are derived from some base 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? (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?, as I am looking to combine a condition like "implements X and NOT extends Y".
Works only in 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.
This lets you search visually for hierarchy patterns.
Here is a diagramm for the JTextComponent
as an example:
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. This enables you to describe your problem as graph query with cypher.
The easiest way to get started is to
- download the binary distribution jqassistant
- run
./bin/jqassistant.sh scan -f your_application.jar
, then - start the server via
./bin/jqassistant.sh server
- and open http://localhost:7474/browser/
- alternatively use the Intellij plugin for jqassistant
Example:
The query for finding all classes implementing aInteface
would look like
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
这篇关于如何识别实现不扩展某些基类的特定接口的所有类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!