Paosin
V2EX  ›  Java

IDEA 如何查询筛选子类调用父类方法?

  •  
  •   Paosin · Oct 14, 2022 via Android · 3123 views
    This topic created in 1499 days ago, the information mentioned may be changed or developed.

    比如说 BaseMapper 有公共的 select 方法

    然后我想查询 UserMapper 在哪些地方调用了父类的 select 方法

    使用 Find usages 会查询所有继承 BaseMapper 子类调用 select 方法,太多了

    由于 UserMapper 声明的变量名称不一定都是 userMapper 所以不能 Ctrl+Shift+f 全局搜索

    有好的办法吗?

    10 replies  •  2022-10-14 10:33:18 +08:00
    panlatent
    panlatent
    Oct 14, 2022
    1
    应该没有直接的功能,你可以在子类里边临时建立个 select 方法, 然后查找子类的 Usages
    Paosin
    Paosin
    OP
    Oct 14, 2022 via Android
    2
    @panlatent 你是说子类重写一下方法再查询吗,我刚试了试查出来的还是全部子类的调用😂
    zoharSoul
    zoharSoul
    Oct 14, 2022
    3
    把继承 BaseMapper 注释了, 看哪些地方报错 /狗头
    xuanbg
    xuanbg
    Oct 14, 2022
    4
    按住 command 键,然后点击方法,不就会列出所有调用了吗?
    Paosin
    Paosin
    OP
    Oct 14, 2022 via Android
    5
    @xuanbg 子类没有重写这个方法,只能去父类点,在父类点查询范围就是所有子类了。不过重写了这个方法点击也是一样的😂
    Paosin
    Paosin
    OP
    Oct 14, 2022 via Android
    6
    @zoharSoul 那不是全报错🐶
    panlatent
    panlatent
    Oct 14, 2022
    7
    @Paosin 你的正常代码 UserMapper 应该没有重写方法吧,现在重写方法了,查到调子类方法 select 的不就是之前调父类方法 select 的么 ? IDEA 会询问你是查找当前方法还是基类方法
    panlatent
    panlatent
    Oct 14, 2022
    8
    如果没有询问可能是你勾选了的不要再次询问? 或者是 IDEA 版本不对?
    lululau
    lululau
    Oct 14, 2022
    9
    `Place' comobox 里选 `Current File'
    Paosin
    Paosin
    OP
    Oct 14, 2022 via Android
    10
    @panlatent 我焯,可能真关了,这个方法可行,谢谢大佬🥰🥰
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1862 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 11:15 · PVG 19:15 · LAX 03:15 · JFK 06:15
    ♥ Do have faith in what you're doing.