You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JDT provides two functionalities for the generation of getters and setters.
Apply the Encapsulate Field refactoring, which generates getters and setters and, in particular, allows to replace references to the field with calls of the generated accessors.
Apply the Generate Getters/Setters source modification, which allows to add getters and setters to the file.
While getter/setter generation can be applied in a batch operation for multiple fields of a class, the refactoring can only be applied to a single field at once.
Expected Behavior
The user shall be able to perform a getter/setter generation together with field encapsulation (i.e., replacement of field access with calls of accessors) in batch mode to multiple fields of a class.
Proposed Solution
Starting from the two existing functionalities, either the getter/setter generation may be extended by functionality to encapsulate the fields, or the field encapsulation refactoring may be enhanced with support for being applied to multiple fields as once.
I propose to follow to second approach, as performing field encapsulation actually is a refactoring that goes beyond source manipulation. I.e., in addition (or as a replacement for the) to the existing Encapsulate Field refactoring, an Encapsulate Fields refactoring should be provided. As a result, the options provided by getter/setter generation and field encapsulation should be aligned. The new refactoring should be capable of everything provided by the existing refactoring but along with a selection of all fiels to apply it to, i.e. :
Selecting the fields to encapsulate (in case of a text selection or when triggered as a quick fix, may be restricted to the fields in the text selection)
Per field:
Defining wheter a getter and/or setter shall be created along with their names
A selection where the method(s) shall be placed
The text was updated successfully, but these errors were encountered:
HeikoKlare
changed the title
Allow Field Encapsulation on Batch Generation of Getters/Setters
Allow Batch Field Encapsulation for Multiple Fields
Sep 25, 2023
Issue: eclipse-jdt/eclipse.jdt.ui#1080
Current Situation
JDT provides two functionalities for the generation of getters and setters.
While getter/setter generation can be applied in a batch operation for multiple fields of a class, the refactoring can only be applied to a single field at once.
Expected Behavior
The user shall be able to perform a getter/setter generation together with field encapsulation (i.e., replacement of field access with calls of accessors) in batch mode to multiple fields of a class.
Proposed Solution
Starting from the two existing functionalities, either the getter/setter generation may be extended by functionality to encapsulate the fields, or the field encapsulation refactoring may be enhanced with support for being applied to multiple fields as once.
I propose to follow to second approach, as performing field encapsulation actually is a refactoring that goes beyond source manipulation. I.e., in addition (or as a replacement for the) to the existing Encapsulate Field refactoring, an Encapsulate Fields refactoring should be provided. As a result, the options provided by getter/setter generation and field encapsulation should be aligned. The new refactoring should be capable of everything provided by the existing refactoring but along with a selection of all fiels to apply it to, i.e. :
The text was updated successfully, but these errors were encountered: