Bug 185330 - [introduce parameter object] does not 'this' qualified field accesses in setter
Summary: [introduce parameter object] does not 'this' qualified field accesses in setter
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Karsten Becker CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-03 09:12 EDT by Benno Baumgartner CLA
Modified: 2007-06-06 12:21 EDT (History)
0 users

See Also:
martinae: review+


Attachments
Qualify this if names collide (2.18 KB, patch)
2007-05-03 10:06 EDT, Karsten Becker CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2007-05-03 09:12:53 EDT
I20070502-0010

Given:
package test;
public class E01 {
	public E01(int number) {}
}
1. Select constructor E01
2. Introduce parameter object
3. Check 'generate setters', accept other defaults
Is:
public void setNumber(int number) {
	number = number;
}
Should:
public void setNumber(int number) {
	this.number = number;
}

Major since with the default settings this only leads to a compiler warning and not an error.
Comment 1 Karsten Becker CLA 2007-05-03 09:53:46 EDT
if the field access is qualified by a this depends on the global setting in code style to qualify field accesses with this.
But should check for name collision and force this.qualifier in case of a collision.
Comment 2 Benno Baumgartner CLA 2007-05-03 10:05:01 EDT
Maybe of interest to you: org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil
Comment 3 Karsten Becker CLA 2007-05-03 10:06:31 EDT
Created attachment 65765 [details]
Qualify this if names collide
Comment 4 Karsten Becker CLA 2007-05-03 10:07:51 EDT
I do use the getterSetterUtil for the method body. But the creation of getter setter stubs is not AST based and considered obsolete therewith.
Comment 5 Martin Aeschlimann CLA 2007-05-03 10:11:29 EDT
patch looks good, will release when M7 is done
Comment 6 Martin Aeschlimann CLA 2007-05-07 11:34:24 EDT
patch reviewed and released > 20070507
Comment 7 Benno Baumgartner CLA 2007-05-16 11:11:16 EDT
verified in I20070516-0010