Eclipse - 内联开放声明?

发布于 2024-12-10 11:04:12 字数 739 浏览 0 评论 0原文

Eclipse 有一个方便的选项,当光标位于方法上时按 f3 即可打开声明。但是,有没有一种方法(通过某些插件或其他方式)可以执行类似的操作,但内联方法体而不是将您带到声明?例如,假设您有两个类:

public class Foo {
    public static void main(String[] args) {
        Bar b = new Bar();
        System.out.println("Value: " + b.value());
    }
}

public class Bar {
    public int value() {
        return 5;
    }
}

然后,如果您将光标放在“b.value()”上并选择此选项,它将显示如下内容:

public class Foo {
    public static void main(String[] args) {
        Bar b = new Bar();
        System.out.println("Value: " + b.value() {
            return 5;
        });
    }
}

理想情况下还能够编辑 value( 的方法主体) ),并且还允许我对 value() 中可能存在的任何其他方法体执行相同的操作。

我这样做的主要动机是为了更快地理解外国代码在做什么。我也愿意接受任何其他支持此功能的 IDE。

Eclipse has the handy option to hit f3 when the cursor is on a method to open the declaration. However, is there a way (via some plugin or otherwise) to do something similar, but inline the method body instead of taking you to the declaration? For example, let's say you have two classes:

public class Foo {
    public static void main(String[] args) {
        Bar b = new Bar();
        System.out.println("Value: " + b.value());
    }
}

public class Bar {
    public int value() {
        return 5;
    }
}

Then, if you put your cursor on "b.value()" and choose this option, it would display something like the following:

public class Foo {
    public static void main(String[] args) {
        Bar b = new Bar();
        System.out.println("Value: " + b.value() {
            return 5;
        });
    }
}

Ideally also being able to edit the method body for value(), and also allowing me to do the same to any further method bodies that may be within value().

My main motivation for this is to more quickly understand what foreign code is doing. I'm also open to any other IDE that supports this feature.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小情绪 2024-12-17 11:04:12

您将需要查看声明视图(窗口 -> 显示视图 -> 声明)。声明视图的内容默认为您的插入符当前选择的任何内容的声明。

或者,您应该能够使用 Shift-Hover 来弹出声明(但我目前无法使该行为发挥作用)。

AFAIK 无法编辑代码。

You will want to look at the declaration view (Window -> Show View -> Declaration). The contents of the declaration view defaults to the declaration of whatever your caret is currently selecting.

Alternatively, you are supposed to be able to use Shift-Hover to get a pop-up of the declaration (but I am currently having trouble getting that behavior to work).

There is no way to edit the code AFAIK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文