Bug 44803 - [introduce parameter] does not replace all occurrences of expression [refactoring]
Summary: [introduce parameter] does not replace all occurrences of expression [refacto...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P4 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard: fix candidate
Keywords:
: 68147 73659 118134 194139 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-14 05:42 EDT by Tobias Widmer CLA
Modified: 2011-02-17 06:51 EST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2003-10-14 05:42:14 EDT
Build 200310101454:

When using the "Introduce parameters" refactoring on the expression 

"JAVADOC_PARAM_TAGS"

and giving the new parameter the name "tags", the result looks as follows:


	protected final boolean isParameterTag(String[] tags) {

		if (fToken != null) {

			for (int index= 0; index < tags.length; index++) {

				if (fToken.equals(JAVADOC_PARAM_TAGS[index])) {

					fToken= null;
					return true;
				}
			}
		}
		return false;
	}

The second occurrence of "JAVADOC_PARAM_TAGS" was obviously not replaced by 
the new parameter.
Comment 1 Markus Keller CLA 2004-05-27 03:54:10 EDT
Introduce Parameter currently doesn't offer an option to replace all occurrences.
Comment 2 Adam Kiezun CLA 2004-06-18 10:22:07 EDT
+1 here
introduce param that replaced all occurences would be a powerful tool for making
methods more reusable. 
i could even imagine a refactoring that would introduce params until a method
could be turned into a static methods and moved to a reusable util class.
Comment 3 Adam Kiezun CLA 2004-06-18 10:27:45 EDT
ha! 
this is a compination of extract temp + introduce param + inline temp
observe:

class A{
 int fField;
  int doubleIt(){
    return fField + fField;
  }
  void caller(){
     int x= doubleIt();
  }
}

now do extract temp:
class A{
 int fField;
  int doubleIt(){
    int i= fField; 
    return i + i;
  }
  void caller(){
     int x= doubleIt();
  }
}

intro param

class A{
 int fField;
  int doubleIt(int p){
    int i= p; 
    return i + i;
  }
  void caller(){
     int x= doubleIt(fField);
  }
}

inline temp
class A{
 int fField;
  int doubleIt(int p){
    return p + p;
  }
  void caller(){
     int x= doubleIt(fField);
  }
}

now you have a reusable doubling method
kinda slow but works. 
Comment 4 Markus Keller CLA 2004-06-22 05:47:15 EDT
*** Bug 68147 has been marked as a duplicate of this bug. ***
Comment 5 Markus Keller CLA 2004-09-10 09:15:03 EDT
*** Bug 73659 has been marked as a duplicate of this bug. ***
Comment 6 Markus Keller CLA 2005-11-28 06:34:08 EST
*** Bug 118134 has been marked as a duplicate of this bug. ***
Comment 7 David Saff CLA 2005-11-29 14:38:57 EST
See also bug 102125, which handles this problem more generally
Comment 8 Martin Aeschlimann CLA 2007-06-25 04:34:40 EDT
*** Bug 194139 has been marked as a duplicate of this bug. ***