Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 433691

Summary: Option to suppress setter for self encapsulation refactoring.
Product: [Eclipse Project] JDT Reporter: Steven Spungin <steven>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: minor    
Priority: P3 CC: noopur_gupta
Version: 4.4   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
screenshot 1
none
screenshot 2
none
screenshot 3 none

Description Steven Spungin CLA 2014-04-28 14:07:22 EDT
see screenshot and patch for details
Comment 1 Steven Spungin CLA 2014-04-28 14:08:10 EDT
Created attachment 242412 [details]
screenshot 1
Comment 2 Steven Spungin CLA 2014-04-28 14:08:25 EDT
Created attachment 242413 [details]
screenshot 2
Comment 3 Steven Spungin CLA 2014-04-28 14:08:39 EDT
Created attachment 242414 [details]
screenshot 3
Comment 4 Steven Spungin CLA 2014-04-28 14:15:22 EDT
Bug 433691 - Option to suppress setter for self encapsulation
Comment 5 Steven Spungin CLA 2014-04-28 14:15:59 EDT
please disregard previous link
https://git.eclipse.org/r/#/c/25687/
Comment 6 Noopur Gupta CLA 2014-04-30 02:28:30 EDT
If you want to generate only the getter and not the setter for a field, you can use the "Generate Getters and Setters" refactoring. You have many other options also in that dialog. (Right-click on field > Source > Generate Getters and Setters)

"Encapsulate Field" refactoring can be used to insert calls to new or existing setter and getter methods at all locations.

For individual locations, once you have created the setter (or getter), you also have the quick assist (Ctrl+1) at that location: "Replace field with setter" (or "Replace field with getter").

For the quick assist "Create getter and setter for field...", see bug 232920.
The fix should be applicable to the quick assist which should allow to generate only the setter or only the getter.

Please note that "Encapsulate Field" refactoring is used not only to generate setter and getter, but also to insert calls to existing setter and getter methods.

*** This bug has been marked as a duplicate of bug 232920 ***
Comment 7 Steven Spungin CLA 2014-04-30 08:24:40 EDT
Bug 232920 suggests that the field should be blank to suppress.  I think the option should be explicit (as I implemented).

I use the quickfix hundreds of times a day, and it would be helpful if the option was in that dialog.

>> Please note that "Encapsulate Field" refactoring is used not only to 
>> generate setter and getter, but also to insert calls to existing setter and >> getter methods.

How does this implementation interface with that?
Comment 8 Noopur Gupta CLA 2014-04-30 13:11:06 EDT
(In reply to Steven Spungin from comment #7)
> Bug 232920 suggests that the field should be blank to suppress.  I think the
> option should be explicit (as I implemented).
That is just one suggestion. Please discuss further in bug 232920.

> >> Please note that "Encapsulate Field" refactoring is used not only to 
> >> generate setter and getter, but also to insert calls to existing setter and >> getter methods.
> 
> How does this implementation interface with that?
It was mentioned to take this behavior also into consideration while fixing the bug. For example, would it also be required to insert calls for only setters or only getters? etc.