使用Eclipse Ganymede进行更细粒度的方法排序:是否有一个好的插件可用?

时间:2023-02-05 11:22:51

These are the options we have out of the box:

这些是我们开箱即用的选项:

alt text http://i39.tinypic.com/2ptnqxl.png

替代文字http://i39.tinypic.com/2ptnqxl.png

I would like a more fine grained sorting when it comes to methods. I would like to:

在方法方面,我想要更细粒度的排序。我想要:

  1. Have all methods with a name which does not start with get, is or set first.
  2. 让所有方法的名称不以get,is或first开头。

  3. Then have the accessor methods (with names starting with get, is or set).
  4. 然后使用访问器方法(名称以get,is或set开头)。

Individually the methods in [1] and [2] above could be sorted in alphabetical order. Apart from my devision of normal methods into two parts I like the existing sort order.

单独地,上面[1]和[2]中的方法可以按字母顺序排序。除了将普通方法分为两部分之外,我还喜欢现有的排序顺序。

I find this order (with the accessor methods last) better as I'm more likely to find the non-accessor methods interesting when I'm maintaining a class and I need to fix a bug etc.

我发现这个顺序(使用访问器方法最后)更好,因为当我维护一个类并且我需要修复bug等时,我更有可能发现非访问器方法很有趣。

Is there a plugin I could use? If there is none, would it be hard to create this kind of plugin myself? (I have never created a Eclipse plugin.)

有没有我可以使用的插件?如果没有,那么自己创建这种插件会不会很难? (我从未创建过Eclipse插件。)

2 个解决方案

#1


I hope it's not to late for my answer.

我希望我的回答不会迟到。

As far as I know, there is no such plugin (I looked at eclipse plugin central right now).

据我所知,没有这样的插件(我现在看着eclipse插件*)。

If you want to write such plugin, it shouldn't be too hard to write the refactoring (the Java Editor is based on an AST, that can be reached via extension points) itself, but for building a working plugin it might need more study.

如果你想编写这样的插件,编写重构(Java编辑器基于AST,可以通过扩展点到达)本身应该不会太难,但是为了构建一个有效的插件,它可能需要更多的研究。

Some resources that might help:

一些可能有用的资源:

  • Plugin development resources from *: question 592391 (sorry, but cannot post two hyperlinks)
  • 来自*的插件开发资源:问题592391(抱歉,但不能发布两个超链接)

  • An open source refactoring plugin: http://code.google.com/p/tane/ (it currently contains a single refactoring plus the related gui elements, it might be a good example for you)
  • 一个开源的重构插件:http://code.google.com/p/tane/(它目前包含一个重构加上相关的gui元素,它可能是一个很好的例子)

#2


In 2011, an academic exercise resulted in an Eclipse plugin implementing methods sorting based on ideas in Robert C. Martin's book "Clean Code". I am still trying to work out if I like it or not.

2011年,一项学术活动导致Eclipse插件基于Robert C. Martin的书“清洁代码”中的想法实现方法排序。如果我喜欢或不喜欢,我仍然在尝试锻炼。

There is an open bug report to enhance sort member functionality in Eclise: Sort Members doesn't provide a means to group getter/setter pairs. It was opened in 2004 and still has no plans to be implemented.

有一个开放的错误报告,用于增强Eclise中的排序成员功能:排序成员不提供对getter / setter对进行分组的方法。它于2004年开放,但仍然没有计划实施。

#1


I hope it's not to late for my answer.

我希望我的回答不会迟到。

As far as I know, there is no such plugin (I looked at eclipse plugin central right now).

据我所知,没有这样的插件(我现在看着eclipse插件*)。

If you want to write such plugin, it shouldn't be too hard to write the refactoring (the Java Editor is based on an AST, that can be reached via extension points) itself, but for building a working plugin it might need more study.

如果你想编写这样的插件,编写重构(Java编辑器基于AST,可以通过扩展点到达)本身应该不会太难,但是为了构建一个有效的插件,它可能需要更多的研究。

Some resources that might help:

一些可能有用的资源:

  • Plugin development resources from *: question 592391 (sorry, but cannot post two hyperlinks)
  • 来自*的插件开发资源:问题592391(抱歉,但不能发布两个超链接)

  • An open source refactoring plugin: http://code.google.com/p/tane/ (it currently contains a single refactoring plus the related gui elements, it might be a good example for you)
  • 一个开源的重构插件:http://code.google.com/p/tane/(它目前包含一个重构加上相关的gui元素,它可能是一个很好的例子)

#2


In 2011, an academic exercise resulted in an Eclipse plugin implementing methods sorting based on ideas in Robert C. Martin's book "Clean Code". I am still trying to work out if I like it or not.

2011年,一项学术活动导致Eclipse插件基于Robert C. Martin的书“清洁代码”中的想法实现方法排序。如果我喜欢或不喜欢,我仍然在尝试锻炼。

There is an open bug report to enhance sort member functionality in Eclise: Sort Members doesn't provide a means to group getter/setter pairs. It was opened in 2004 and still has no plans to be implemented.

有一个开放的错误报告,用于增强Eclise中的排序成员功能:排序成员不提供对getter / setter对进行分组的方法。它于2004年开放,但仍然没有计划实施。