Bug 176632 - [extract local] does not always work correcty with statements/blocks that receive parameters.
Summary: [extract local] does not always work correcty with statements/blocks that rec...
Status: RESOLVED DUPLICATE of bug 27740
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-07 13:35 EST by Frederico Guimarães CLA
Modified: 2007-03-08 13:10 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederico Guimarães CLA 2007-03-07 13:35:36 EST
When you use the "extract local variable" rafactor in a statement/block that receive parameters the result code may not has the same result as the original code.

Example:

====================================================
...
int i;
....
Matcher m;
....

// i =0;

int did = Integer.parseInt( m.group( ++i ) );
int ddd = Integer.parseInt( m.group( ++i ) );
int ddi = Integer.parseInt( m.group( ++i ) );

==================================================== 

If the refactor "extract local variable" is used on the first "m.group( ++i )"

The resulting code does not do the same thing...

====================================================
...
int i;
....
Matcher m;
....

// i =0;

String didStr = m.group( ++i );
int did = Integer.parseInt( didStr );
int ddd = Integer.parseInt( didStr );
int ddi = Integer.parseInt( didStr );

==================================================== 

In the resulting code the variable did, ddd, ddi will have the same value, and i will value 1 at the end of the code.
In the original code did, ddd, ddi probably will have differente values and i will value 3 at the end.

I think this glitch happen, because this refactor does no test if the parameters ( i in the case ) are modified in the code.
Comment 1 Olivier Thomann CLA 2007-03-07 13:40:30 EST
Move to JDT/UI.
Comment 2 Markus Keller CLA 2007-03-08 13:10:05 EST

*** This bug has been marked as a duplicate of bug 27740 ***