可以将eclipse转换/重构一个方法到一个类吗? [英] Can eclipse convert/refactor a method to a class?
问题描述
这是重构遗留代码时经常遇到的重复任务。无论如何,我目前正在使用Eclipse 3.0.2,但是如果可以在更新版本的eclipse中使用Eclipse,那么仍然会对这个答案感兴趣。谢谢!
我不认为这种重构存在。
Bug 225716 有(2008年初以来)。
错误312347 也是一个很好的实现这样的重构。
创建一个新课程,并将相关领域和方法从旧类移动到新类中。
我在此 SO答案中提到了解决方法。
This seems like it should be fairly straight-forward, but I can't see anything obvious. What I basically want to do it to point at a method and refactor->extract class. This would take the method in question to a new class with that method as top level public API. The refactoring would also drag any required methods and variables along with it to the new class, deleting them from the old class if nothing else in the old class is using it.
This is a repetitive task I often encounter when refactoring legacy code. Anyway, I'm currently using Eclipse 3.0.2, but would still be interested in the answer if its available in a more recent version of eclipse. Thanks!
I don't think this kind of refactoring exists yet.
Bug 225716 has been log for that kind of feature (since early 2008).
Bug 312347 would also be a good implementation of such a refactoring.
"Create a new class and move the relevant fields and methods from the old class into the new class."
I mention a workaround in this SO answer.
这篇关于可以将eclipse转换/重构一个方法到一个类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!