Bug 11452 - extract method: could replace all occurrences of expression [refactoring]
Summary: extract method: could replace all occurrences of expression [refactoring]
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: 3.0 M2   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 23088 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-15 07:03 EST by Adam Kiezun CLA
Modified: 2003-07-28 05:14 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-03-15 07:03:34 EST
extract method could replace more than 1 occurence of extracted code

in the simplest case - if extracting 1 expression, it could replace all 
occurences in the current method

int m(int p){
   int i= /*[*/m(m(1))/*]*/;
   int j= m(m(1)) + m(m(1));
   return p+1;
}
could be refactored to:

int m(int p){
   int i= three();
   int j= three() + three();
   return p+1;
}

in a more compilacted case, it could find occurences of code in the same cu
(but then, you must compare bindings - identified 'i' may mean different things 
in different methods)
and, it's not matching 1 node then - you must match a sequence of nodes possibly

i'd be happy with the simple case (although it's possible to achieve the same 
goal by using 'extract temp' and 'inline temp')
Comment 1 Erich Gamma CLA 2002-03-15 08:49:12 EST
would be interesting extending the scope beyond a single method.
Comment 2 Dirk Baeumer CLA 2002-07-23 09:45:15 EDT
[refactoring]

Consider for 2.1
Comment 3 Dirk Baeumer CLA 2002-10-08 12:15:56 EDT
*** Bug 23088 has been marked as a duplicate of this bug. ***
Comment 4 Dirk Baeumer CLA 2003-04-28 06:02:26 EDT
Chaning state from assigned later to resolved later. Assigned later got 
introduced by the last bug conversion and is not a supported Eclipse bug state.
Comment 5 Nikolay Metchev CLA 2003-07-21 06:01:25 EDT
It looks like this was addressed in M2. I suggest that people that voted for 
this vote for something else now. 
Comment 6 Dirk Baeumer CLA 2003-07-28 05:14:26 EDT
Correct, got addressed for M2.
Comment 7 Dirk Baeumer CLA 2003-07-28 05:14:42 EDT
Fixed