简体   繁体   English

如何识别实现不扩展某些基类的特定接口的所有类?

[英]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 最简单的入门方法是

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.

相关问题 如何获得在特定OSGi Bundle中实现接口的所有类 - How get all classes implementing an interface in a specific OSGi Bundle 如何为扩展特定类的所有类指定单个切入点 - How to specify single pointcut for all classes that extend a specific class Proguard模糊处理软件包,不包括扩展/实现某些接口/类的类 - Proguard obfuscate package excluding classes extending/implementing some interface/class 为什么坚持接口的所有实现都扩展了基类? - Why insist all implementations of an interface extend a base class? 实现接口方法的类(没有显式实现该接口)是否扩展了该特定接口? - Does a class which implements an interface's method (without explicitly implementing that interface) extend that specific interface? 在运行时,查找 Java 应用程序中扩展基类的所有类 - At runtime, find all classes in a Java application that extend a base class 如何将Serializable接口扩展到所有子类? - How to extend the Serializable interface to all sub Class? 在Intellij IDEA中,找到实现接口但不扩展另一个类的类 - In Intellij IDEA, find classes that implement an interface but do not extend another class 如何在不强制转换的情况下获得实现通用接口的特定类的Factory? - How do I get a Factory of specific classes implementing a generic interface without having to cast? Java:当其他类已经扩展基类时,如何扩展基类? - Java: How to extend a base class when other classes already extend the base?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM