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.
Consider this code: private void test() { inline(); } private void inline() { System.out.println("Test1"); //Hmmm What now? System.out.println("Here"); } Now do an inline refactoring on the inline() method: This is what is the result: private void test() { System.out.println("Test1"); System.out.println("Here"); } This is even worse for larger method, the completely loose all the formatting and comments, which is an unusable refactoring for larger methods. Expected: Keep all exsiting formatting and comments Product Version = NetBeans IDE 7.4 RC1 (Build 201309162201) Operating System = Linux version 3.8.0-30-generic running on amd64 Java; VM; Vendor = 1.7.0_40 Runtime = Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Created attachment 145154 [details] Shows the issue Another example: * Take the following code package com; public class Main { private void bar() { //TODO barbar foo(); //TODO barbar } private void foo(){ //TODO blabla System.out.println("this = " + this); //TODO blabla } } * Inline foo() ACTUAL: (comments are lost) package com; public class Main { private void bar() { System.out.println("this = " + this); //TODO barbar } } EXPECTED: (comments are retained) package com; public class Main { private void bar() { //TODO barbar //TODO blabla System.out.println("this = " + this); //TODO blabla //TODO barbar } } When will this be fixed? It is very annoying to review the generated code after many of those simple refactorings.
Created attachment 146991 [details] Proposed patch Using the following patch package com; public class Main { private void bar() { //TODO barbar foo(); //TODO barbar } private void foo(){ //TODO blabla System.out.println("this = " + this); //TODO blabla } } can be transformed (at least) into package com; public class Main { private void bar() { //TODO blabla System.out.println("this = " + this); //TODO blabla } } but I could not figure out how to preserve the original "barbar" comments. BTW: In org.netbeans.modules.refactoring.java.plugins.InlineMethodTransformer there are also two other locations where the tree is rewritten. @Ralph: Please review!
changeset : e0a6cabca94c author : Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org> date : Tue May 20 16:00:05 CEST 2014 summary : #236447 - [Inline] Inline looses all formatting and comments The fix is a bit more complicated than the proposed patch. Comments are ignored if the tree is not new or changed.
Integrated into 'main-silver', will be available in build *201405230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/e0a6cabca94c User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org> Log: #236447 - [Inline] Inline looses all formatting and comments