Paosin
V2EX  ›  Java

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

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