gpt4 book ai didi

NetBeans 更改 "create method"提示行为

转载 作者:行者123 更新时间:2023-12-01 05:05:32 25 4
gpt4 key购买 nike

假设我在 NetBeans 中有这段 Java 代码

public class Clazz {

public void method1() {
method3(); // here is my cursor
}

public void method2() {

}

}

所以我按 Alt+Enter 提示“创建方法”,它在类(class)结束时创建我的方法。
public class Clazz {

public void method1() {
method3();
}

public void method2() {

}

private void method3() {
throw new UnsupportedOperationException( "Not supported yet." );
}

}

所以 我的问题是如何在当前方法下创建方法? 就像这样:
public class Clazz {

public void method1() {
method3();
}

private void method3() {
throw new UnsupportedOperationException( "Not supported yet." );
}

public void method2() {

}

}

感谢您的时间 :)

最佳答案

不幸的是,这是不可能的。较早的 bug report关于此功能生成的代码的放置已被驳回:

The method position is not easy to correct and changes would be possibly inconsistent with other generation behaviour -- currently, we insert the method at the end of block of class members with same priority (GeneratorUtilities ClassMemberComparator).

关于NetBeans 更改 "create method"提示行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29209206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com