How to generate Java call hierarchy in IntelliJ IDEA for overridden methods

249 Views Asked by At

I need to analyze the call hierarchy of methods in a Java Spring Boot application.

IntelliJ IDEA gets confused when I have:

  • a interface I declaring I.foo()
  • an abstract class A with implementation of I.foo()
  • several concrete classes B, C etc extending A and B overrides A.foo()

I'd like to get the call hierarchy of B.foo() however I get also all callers of C.foo().

If that matters, the classes are autowired similar to the following:

@Component
public class Caller1 {
   @Autowired B b;

   public void bar(){ b.foo()} 
}

@Component
public class Caller2 {
   @Autowired C c;

   public void bar(){ c.foo()} 
}

public interface I {
   void foo();
}

public abstract class A implements I {
   void foo(){..}
}

@Component
public B extends A {
   @Override
   void foo() {..}
}

@Component
public C extends A {
   ..
}

In IntelliJ IDEA, the call hierarchy of B.foo() includes both Caller1.bar() and Caller2.bar(). But I only want callers of B.foo() such as Caller1.bar().

0

There are 0 best solutions below