【问题标题】:Intellij shortcut directly go to any variable Class or methodIntellij 快捷方式直接转到任何变量类或方法
【发布时间】:2021-04-27 12:43:22
【问题描述】:
SomeClass {
   AbstractType/Interface instanceVariable = new SpecificType();

   ...

   SomeFn(){
     instanceVariable.instanceMethod();
                           | <- go to SpecificType.instanceMethod() directly
     
     instanceVariable.instanceMethod();
           | < go to SpecificType of instanceVariable directly
}

寻找 Intellij 快捷方式以转到变量的特定类。在大型代码中转到 instanceVariable 并希望转到其 SpecificType 类。它需要三个命令,使用 Go to Declaration (F3) 转到 instanceVariable 定义,查看其定义,将光标移动到实际类型 new SpecificType();,进入并返回您使用的位置 (Command + [)。我们也可以使用 F2 将鼠标悬停在“instanceVariable”定义上以查看其类型,但是,没有直接的快捷方式可以转到定义此实例变量的实际类“SpecificType”。

与 instanceMethod() 相同,在此实例的方法上 (Shift+Command+I) 有“Go to Implementation”并选择特定类型,而实例已在类中定义为“SpecificType”。使用F2查看方法类型查看哪个类,在这种情况下,它会显示方法类型所属的“SpecificType”,然后选择具体的实现并从几个下拉菜单中选择SpecificType。

如果有一个快捷方式可以直接指向特定类型类或其方法而不是多个命令,那就太好了。

【问题讨论】:

    标签: intellij-idea keyboard-shortcuts intellij-14


    【解决方案1】:

    为什么选择主菜单 |导航 | Go to Implementation(s) 操作(Alt+Cmd+B 默认快捷键)对您不起作用?在方法调用上调用它,然后从下拉列表中选择您感兴趣的实现:

    【讨论】:

    • 对,但我的问题不是从下拉菜单中选择变量还是方法。 IntelliJ 有足够的智能知道它已经是正确的 instanceVariable 类型,SpecificType 大多数时候可以是最终的具体类。
    猜你喜欢
    • 1970-01-01
    • 2011-05-02
    • 2015-11-05
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    相关资源
    最近更新 更多