Community
Participate
Working Groups
I have two classes: A - with private field and getter for it. public class A { private int m_Field; public int getField() { return m_Field; } } And B, which attepts to use field from A (accidently, due "Move" refactoring) class B { private A a; public int foo() { return a.m_Field * 2; } } Now there is only one possible fix for "a.m_Field" - change visibility. Would be great to have also item for "Use getter" or someting like this.
*** Bug 26824 has been marked as a duplicate of this bug. ***
bug 26824 suggests to offer to create a getter when not existing
Dirk also commented that a 'create getter' should have higher priority than 'change visibility to public'
not for 3.0
reopened for 3.1
*** Bug 75870 has been marked as a duplicate of this bug. ***
I agree that the "create getter" should have a higher priority than "make visible". It would be fine with me if the create-getter action would invoke the usual Create Getter/Setter dialogue, with only the getter checked.
*** Bug 65597 has been marked as a duplicate of this bug. ***
*** Bug 78796 has been marked as a duplicate of this bug. ***
Created attachment 62241 [details] Change to getter/setter if available This patch does not offer to create a getter/setter yet. It simply offers to change to an available one. The detection of getters/setters for fields with prefixes does not work yet because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=179506
Created attachment 62780 [details] Invoke SelfEncapsulateField if not Getter/Setter The SEF dialog has been slightly improved and ignores problems that are likely to be solved by this refactoring.
+1 for 3.3M7
Created attachment 63039 [details] Patch after Review Checks for static modifier match of field and method. UI disables not applicable fields.
patch released > 20070413 to be done: - include quick fix for unqualified again. I commented it out as existing tests need to be adapted - avoid testing the order of tests - think of adding 'Encapsulate field' as quick assist.
Created attachment 65931 [details] Additional Tests Unqualified Tests in LocalCorrections updated SEF Test in ModifierCorrectionsTest
patch is good (not minimal, but the formatting changes are good)
Benno, can you do the second review?
- Do not even THINK about catching java.lang.Exception;-) - Do not print to console (e.printStackTrace()) - Fields in ProposalParameter must have f prefix - Use getters for private fields - Not sure about this, but I usually see the following pattern in our code: if (Display.getCurrent() != null) { perform(...); } else { Display.getDefault().syncExec(new Runnable() { public void run() { perform(...); } }); } Ask Martin...
Created attachment 68572 [details] Addressed open issues ProposalParameter fields do not start with f because they are parameters as discussed with martin. That is why they also do not have getters.
fixed > I20070524-0010 Changed: - Correct formatting - Made fields 'public' - Using Display.getDefault()
verified in I20070527-0010 Filed Bug 189606