如何在 IntelliJ IDEA 中为覆盖方法生成 Java 调用层次结构

问题描述

我需要分析 Java Spring Boot 应用程序中方法调用层次结构。

IntelliJ IDEA 在我遇到时感到困惑:

  • 一个接口 I 声明 I.foo()
  • 一个抽象类 A,实现了 I.foo()
  • 几个具体的类 BC 等扩展 AB 覆盖 A.foo()

我想获取 B.foo()调用层次结构,但我也获取 C.foo() 的所有调用者。

如果这很重要,类会自动装配,类似于以下内容

@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 {
   ..
}

在 IntelliJ IDEA 中,B.foo()调用层次包括 Caller1.bar()Caller2.bar()。但我只想要 B.foo()调用者,例如 Caller1.bar()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)