Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350037 - [getter setter][rename] "Rename field" doesn't recognize getter and setter methods
Summary: [getter setter][rename] "Rename field" doesn't recognize getter and setter me...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P4 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-22 07:54 EDT by Gerrit CLA
Modified: 2011-11-15 03:24 EST (History)
4 users (show)

See Also:


Attachments
An example class. (220 bytes, application/octet-stream)
2011-06-22 08:03 EDT, Gerrit CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerrit CLA 2011-06-22 07:54:48 EDT
Build Identifier: M20110210-1200

If there are fields with consist of one lower case character followed by an upper case character (like iCount) the rename function doesn't recognize existing getter and setter methods and therefore doesn't rename them. I will attach an example class.

Reproducible: Always

Steps to Reproduce:
1. Put the cursor position on a occurance of a field that matches the criteria metioned in the bug details.
2. Open the "Rename field" dialog (Alt+Shift+R or using the menu).
3. The checkboxes "Rename getter method" and "Rename setter method" are disabled.
Comment 1 Gerrit CLA 2011-06-22 08:03:20 EDT
Created attachment 198391 [details]
An example class.

If I try to rename the field iCount in this example, the Eclipse refactoring doesn't recognize the methods getICount() and setICount(int) as getter and setter methods of that field. The checkboxes "Rename getter method" and "Rename setter method" are disabled in the "Rename field" dialog.
Comment 2 Gerrit CLA 2011-06-22 08:18:26 EDT
It definitly worked in Version 3.3.2 (Build id: M20080221-1800).
Comment 3 Olivier Thomann CLA 2011-06-24 12:18:22 EDT
Moving to JDT/UI
Comment 4 Deepak Azad CLA 2011-10-18 21:31:13 EDT
Indeed, this works as described till 3.4, but not from 3.5 onward.

With no field prefixes defined, for a field named 'iCount' we expect the getter and setter names as

Till 3.4 - getICount() and setICount(int)
Since 3.5 - getiCount() and setiCount(int)

I prefer the old behavior. Markus ?
Comment 5 Dani Megert CLA 2011-10-25 07:21:36 EDT
(In reply to comment #4)
> Indeed, this works as described till 3.4, but not from 3.5 onward.
> 
> With no field prefixes defined, for a field named 'iCount' we expect the getter
> and setter names as
> 
> Till 3.4 - getICount() and setICount(int)
> Since 3.5 - getiCount() and setiCount(int)
> 
> I prefer the old behavior. Markus ?

This probably got changed with bug 38111. Both can be seen as correct depending on the personal taste. The discussion about this (if needed) should be done in a separate bug.

Regarding this bug here: we should be more open when trying to rename the getters and setters and ignore the casing of the first character after get/set.

Deepak, please take a look.
Comment 6 Markus Keller CLA 2011-10-26 08:44:53 EDT
The behavior change in 3.5 is due to bug 154823, which aligned our behavior with the Java Beans specification.

If you set "i" as field prefix on the Java Code Style page in the project properties, then the Rename Field refactoring identifies get/setCount() methods as getter/setter for field iCount.

I don't think we should change anything here.