Community
Participate
Working Groups
Start with: public class Test { int fFoo, fBar; } "Encapsulate field..." fFoo. This yields in: public class Test { private int fFoo, fBar; void setFoo(int foo) { fFoo = foo; } int getFoo() { return fFoo; } } However, if some classes in the package refer to fBar, the code becomes uncompilable, because fBar is now private too....
Move to JDT/UI.
Depends on overall 3.0 planning.
Created attachment 8144 [details] Patch fixing the problem The patch creates new private variable declaration if original declaration contains more than one fragment. Also it fixes a problem when encapsulated field is declared inside anonymous class. Previous implementation added getter and setter to the outer class. Dirk, I didn't find any unit tests for encapsulate field refactoring. If you tell me where they are then I will add new test case verifying this fix.
The test cases are named SefTests and the resources folder is named SefWorkSpace.
Created attachment 8612 [details] The updated patch can be applied to latest HEAD
Patch verified and released for M8. For the record (I change ASTNode.getBodyDeclarations() to reflect current changes of the AST).