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.
[ BUILD # : 201211260002 ] [ JDK VERSION : 1.7.0_09 ] Missing fixable hint which renames the current file to match the class name Steps: * you have a public java class named "Foo" within file "Foo.java" * now you change the class name to "Bar" within the editor (file name is still Foo.java) --> the error "class Bar is public, should be declared in a file named Bar.java" is shown ACTUAL: no fixable hint EXPECTED: fixable hint "Rename file to Bar.java" See screenshot for current behaviour
Created attachment 128455 [details] Shows the current error
Created attachment 133682 [details] Proposed patch v1 @Jan: I like to propose the following patch to solve this RFE. Please review! The patch introduces two fixable hints (Rename type to ..., Rename file to ...) See the unit test for 'living' examples. There is one problem I couldn't solve by myself: A modified, but non-saved document has to be saved before applying the fixes. Else there'll be exceptions. But I didn't find out how to. See the TODO markers in the source code. Can you help out?
Created attachment 133683 [details] Shows the patch in action
(In reply to comment #2) > Created attachment 133682 [details] > Proposed patch v1 > > @Jan: I like to propose the following patch to solve this RFE. Please review! Actually, I added the change filename fix almost three weeks ago: http://hg.netbeans.org/jet-main/rev/aca3b1c24bb8 No idea why the automatic note was not added to the report - probably some glitch during the infrastructure conversion (or a mistake in the changeset message, although I don't see any). > > The patch introduces two fixable hints (Rename type to ..., Rename file to ...) > See the unit test for 'living' examples. > > There is one problem I couldn't solve by myself: A modified, but non-saved > document has to be saved before applying the fixes. Else there'll be > exceptions. But I didn't find out how to. See the TODO markers in the source > code. Can you help out? Regarding renaming/moving the file, this cannot really be done using FileObjects, DataObjects need to be used (see the patch above). Regarding changing the class' name, I did not see the exceptions, so I have no idea about their possible cause. However, I tend to believe the rename refactoring should be brought up (so that if there is another class that uses the broken one, the usage is renamed alongside with the broken class). But I was not able to make this work with reasonable effort, IIRC. In any case, please don't parse the diagnostic messages unless absolutely necessary (which it's not in this case - using the information from the file&tree is actually easier in this case, IMO).
(In reply to comment #4) > Actually, I added the change filename fix almost three weeks ago: > http://hg.netbeans.org/jet-main/rev/aca3b1c24bb8 > > No idea why the automatic note was not added to the report - probably some > glitch during the infrastructure conversion (or a mistake in the changeset > message, although I don't see any). Oh, I see. The issue was still open and I don't fetch the repo very often, because the hints can be developed in isolation. It's OK. I guess it isn't synced because this issue isn't marked as closed/fixed. Do you like to close it? > > Regarding renaming/moving the file, this cannot really be done using > FileObjects, DataObjects need to be used (see the patch above). > Good to know for the future. > However, I tend to believe the rename > refactoring should be brought up (so that if there is another class that uses > the broken one, the usage is renamed alongside with the broken class). But I > was not able to make this work with reasonable effort, IIRC. Yes that would be the best solution, but I also had no time and concentration to look at this. Let's keep this for a future RFE, if someone will ever report such an issue. > In any case, please don't parse the diagnostic messages unless absolutely > necessary (which it's not in this case - using the information from the > file&tree is actually easier in this case, IMO). I will keep this in my mind too. I'm glad to have you as a reviewer to learn the best practices. Thanks. Benno
(In reply to Jan Lahoda from comment #4) > Actually, I added the change filename fix almost three weeks ago: > http://hg.netbeans.org/jet-main/rev/aca3b1c24bb8 So resolving as fixed