java - 如何根据 Eclipse 中的使用情况对 Java 类的方法/成员进行排序?

标签 java eclipse

<分区>

CleanCode 一书建议按调用顺序对函数进行排序:

If one function calls another, they should be vertically close, and the caller should be above the callee, if at all possible. This gives the program a natural flow.

我想将该顺序包含在我的清理程序中。下面的例子

public void content(){
   primary();
   secondary();
}   

private void secondary(){

}

private void primary(){

};

应该自动重新排序为

public void content(){
   primary();
   secondary();
}

private void primary(){

};

private void secondary(){

}

(这不是字母顺序,primary() 和 secondary() 具有相同的修饰符。)

但是,我找不到这样做的 Eclipse 功能。 Eclipse 似乎只能按成员的类型而不是按用途对成员进行排序。

是否有我错过的默认功能或我可以安装的额外 Eclipse 插件?

(我不是在寻找或提供该顺序的大纲 View 。我想更改代码中的实际顺序。这个问题不是关于以这种方式更改代码的利弊。)

相关文章:

How to specify the order of class members when formatting in Eclipse

最佳答案

感谢 ProgrammersBlock 的评论,我发现这个插件处于 Beta 状态:

http://wiki.eclipse.org/Recommenders/CleanCodeMethodSorter

关于java - 如何根据 Eclipse 中的使用情况对 Java 类的方法/成员进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41485674/

相关文章:

java - 从 eclipse 中的工作区导入项目

eclipse - scala sbt 缓存 x eclipse 构建路径

eclipse - 更改 Subversive 存储库标签

java - 为什么 m 方法的可见性会以这种方式改变输出?我预计会发生相反的情况

java - EventSource onmessage() 在 onopen() 和 onerror() 正常工作的地方不工作?

java - Splash-Screen 在 IDE 中工作,但不能以 .jar 形式工作 - ANT 问题?

java - ReSTLet Protocol.FILE 用法

java - 无法在 android :onClick attribute defined on view class android. widget.ImageView 的父级或祖先上下文中找到方法

java - Eclipse IDE 中的 AccessController.doPrivileged() 问题

android - Openni、Android 和 PrimeSense 设置