Java – How do I identify all classes that implement a specific interface but do not extend some base class?

How do I identify all classes that implement a specific interface but do not extend some base class?… here is a solution to the problem.

How do I identify all classes that implement a specific interface but do not extend some base class?

I have some interface actions, and most of the classes that implement the interface derive from some base class, AbstractAction. But I assume that there are some classes that implement the interface, but do not extend the base class.

Is there a way to use IntelliJ to identify this class? (Ideally: use the Community Edition).

EDIT: This is not How to show all parents and subclasses of a class in IntelliJ IDEA? copy, because I want to combine conditions like “implement X instead of extending Y”.

Solution

Available only for Intellij IDEA Ultimate:
The only way I can think of solving your problem directly with Intellij IDEA is to generate uml class diagramm Action interface.

This allows you to visually search for hierarchical patterns.

The following is an example of a diagram for JTextComponent:

enter image description here

Another way – use the right tools for the job

jqassistant is a tool that analyzes your Java code and its relationships and stores it in the Neo4j database.
This enables you to describe the problem as a graphical query cypher

The easiest way to get started is

Example:
A query to find all classes that implement aInteface looks like

MATCH (i:Interface {name:"aIntefaces"}  )<-[:IMPLEMENTS]- (c) RETURN i,c

The query for your question is as follows:

MATCH 
   (i:Interface {name:'Action'}  )<-[:IMPLEMENTS| EXTENDS*1..10]- (class), 
   (abstractAction:Class {name:'AbstractAction'}) 
   where not (class)-->(abstractAction)   
RETURN class

Related Problems and Solutions