Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Batch Field Encapsulation for Multiple Fields #13

Open
HeikoKlare opened this issue Sep 25, 2023 · 0 comments
Open

Allow Batch Field Encapsulation for Multiple Fields #13

HeikoKlare opened this issue Sep 25, 2023 · 0 comments
Assignees
Labels
Enhancement A Request for an Enhancement of an Existing Feature JDT Issues for JDT

Comments

@HeikoKlare
Copy link
Contributor

HeikoKlare commented Sep 25, 2023

Issue: eclipse-jdt/eclipse.jdt.ui#1080

Current Situation

JDT provides two functionalities for the generation of getters and setters.

  1. 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.
    Image
  2. Apply the Generate Getters/Setters source modification, which allows to add getters and setters to the file.
    Image

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
@HeikoKlare HeikoKlare converted this from a draft issue Sep 25, 2023
@HeikoKlare HeikoKlare added JDT Issues for JDT Enhancement A Request for an Enhancement of an Existing Feature labels Sep 25, 2023
@HeikoKlare HeikoKlare moved this from 📋 Backlog to 🔖 Ready in Eclipse Sep 25, 2023
@HeikoKlare HeikoKlare changed the title Allow Field Encapsulation on Batch Generation of Getters/Setters Allow Batch Field Encapsulation for Multiple Fields Sep 25, 2023
@amartya4256 amartya4256 self-assigned this Dec 20, 2023
@amartya4256 amartya4256 moved this from 🔖 Ready: Atomic to 🏗 In Work: Short in Eclipse Jan 25, 2024
@amartya4256 amartya4256 moved this from 🏗 In Work: Short to 👀 In Review in Eclipse Jan 25, 2024
@amartya4256 amartya4256 moved this from 👀 In Review to ✅ Done in Eclipse May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A Request for an Enhancement of an Existing Feature JDT Issues for JDT
Projects
Status: Done
Development

No branches or pull requests

2 participants