Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.6.0.Release
-
Fix Version/s: None
-
Component/s: Refactoring
-
Labels:None
-
Number of attachments :
Description
Groovy-Eclipse can implement a refactoring called "Extract to Category". This refactoring will take an existing method and extract it to a category class. It will convert the method to static and add an additional parameter. This will be similar to the AspectJ "Pull-out" refactoring (and this may be a more appropriate name for the refactoring. Here is an example:
Existing code:
class Flar {
def blah
String myMethod(arg1, arg2) {
this.blah blah.blah
}
}
Invoking the refactoring will bring up a dialog where you choose which methods to extract (users should be able to choose multiple) and you choose a target type. Final code will look like this:
class Flar {
def blah
}
// FlarCategory.groovy
class FlarCategory {
static String myMethod(Flar self, arg1, arg2) {
self.blah self.blah.blah
}
}
A tricky piece will be ensuring that references (implicit or not) to this are changed to self references.