Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 160853 - [extract method] Does not replace similar code in parent class of anonymous class
Summary: [extract method] Does not replace similar code in parent class of anonymous c...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Benjamin Muskalla CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-13 09:04 EDT by Benno Baumgartner CLA
Modified: 2009-08-04 08:41 EDT (History)
4 users (show)

See Also:


Attachments
patch (7.04 KB, patch)
2009-06-30 19:04 EDT, Benjamin Muskalla CLA
markus.kell.r: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2006-10-13 09:04:24 EDT
I20061010-0800

Given:
package a.b;
public class Foo {
	public void foo() {
		Object obj= new Object() {
			public String toString() {
				return "foo." + getName();
			}
		};
		String s= "foo." + getName();
	}
	
	private String getName() {return "bar";}
}

1. Select _second_ expression "foo." + getName()
2. Refactor>Extract Method...
3. extract method 'qualifiedName'
Is:
 both expressions "foo." + getName() are replaced by a call to qualifiedName, correct.
4. Undo
5. Select first expression "foo." + getName()
6. Refactor>Extract Method...
7. Select 'Foo' as destination type
8. extract method 'qualifiedName'
Is:
 Only first expression is replaced by call
Should:
 Both expression should be replaced, at least I can't see no difference...
Comment 1 Benjamin Muskalla CLA 2009-06-30 19:04:51 EDT
Created attachment 140552 [details]
patch

Suggested patch
Comment 2 Markus Keller CLA 2009-07-13 12:05:56 EDT
Thanks, released to head (updated copyright date and put copyright entry on one line).
Comment 3 Raksha Vasisht CLA 2009-08-04 04:49:52 EDT
Verified for 3.6 M1 using I20090803-1800
Comment 4 Dani Megert CLA 2009-08-04 08:41:16 EDT
The fix for this bug causes a collateral damage: in case of extracting into the anonymous class it enables the checkbox for other occurrences (see bug 285569).