This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Extracting a method does not detect other similar code fragments and replace them with invocation to new method. Extracting a method should have an effect as shown below. But currently it replaces only at the location from which the refactoring was initiated. Before Refactoring: public class Sample { public void method1(String str) { String newStr = str + "_abc"; // Do something on newStr. } public void method2(String anotherStr) { String anotherNewStr = anotherStr + "_abc"; // Do something else on anotherNewStr. } } After Refactoring: public class Sample { public void method1(String str) { String newStr = addSuffix(str); // Do something on newStr. } public void method2(String anotherStr) { String anotherNewStr = addSuffix(anotherStr); // Do something else on anotherNewStr. } private String addSuffix(String anotherStr) { return anotherStr + "_abc"; } }
It is org-netbeans-modules-java-hints-introduce-IntroduceMethodAction. Please do not change the component.
6.9 has the ability to find duplicates code for introduce method. This does not work for introduce method from expression, which is rather a bug. Fixed by local changeset 8ac9e0d326c5.
Should be fixed by the above changeset.