Project: JDT
Bug 305103 [refactoring] Comment deleted on 'Move type to new file' refactoring
Reported: 2010-03-09 01:21:28 | Status: verified fixed

For each code snippet below - Move X to new file (problem is independent creating an instance variable) - The comment gets deleted. Its neither in new file nor the old file. - There can be some empty lines between the comment and class X, the comment will still be deleted However if the comment is a javadoc (begins with /**) then its moved to new file. Marking as major as there is loss of data and the user may not realize it right away. Also I do not see any junits which test these (comments) cases. 1) package p; class A { /* * A very important comment. */ class X { } } 2) package p; class A { /* * A very important comment. */ class X { } } 3) package p; class A { // A very important comment. class X { } } 4) package p; class A { class X { } // A very important comment. } 5) package p; class A { class X { } /* A very important comment.*/ } 6) package p; class A { class X { } /** A very important comment.*/ } Things that work fine - Javadoc comment before Class X Empty lines between Class X and the comment when comment occurs after the class 1) package p; class A { /** * A very important comment. */ class X { } } 2) package p; class A { class X { } // A very important comment. } 3) package p; class A { class X { } /* A very important comment.*/ } 4) package p; class A { class X { } /** A very important comment.*/ }

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test35/out/Inner.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test36/out/Inner.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_45/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_45/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_45/out/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_46/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_46/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_46/out/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_47/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_47/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_47/out/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_48/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_48/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_nonstatic_48/out/B.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_10/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_10/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_10/out/Secondary.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_11/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_11/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_11/out/Secondary.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_12/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_12/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_12/out/Secondary.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_13/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_13/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_13/out/Secondary.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_9/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_9/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/MoveInnerToTopLevel/test_secondary_9/out/Secondary.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java