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.
Summary: | After you rename the node of a form in Explorer, not all occurencies of the name in the source code are replaced. | ||
---|---|---|---|
Product: | editor | Reporter: | Antonin Nebuzelsky <anebuzelsky> |
Component: | Refactoring | Assignee: | issues@java <issues> |
Status: | CLOSED FIXED | ||
Severity: | enhancement | CC: | ttran |
Priority: | P1 | ||
Version: | 4.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: |
Description
Antonin Nebuzelsky
2000-09-04 10:02:31 UTC
This is not a bug... Only class name and constructors are renamed - the rest is the user's code that should not be modified by the IDE at all (especially not the comments). (The only exception are IDE-managed guarded blocks.) I understand what you mean. But from the user's point of view it seams to me that Forte should always generate only code that is compilable and runnable. In this particular case, Forte created the whole source code itself from a template. After the renaming, the compilation of the code will produce errors because the class referenced from main() method does not exist. Couldn't Forte just replace all occurencies of the old string? I see that in some cases this could change the code unexpectedly, but a question could be given to the user in such unclear cases. Svata, what do you think about this? Hmm, maybe we may make it configurable somewhere and ask the user for the first time (something like the Add to Project question) dialog. I don't like the idea too much (string searches in a Java code are always awful), but I can be convinced after all ;-) Anyway, only simple names (without any outerclass/package qualification) or fully qualified ones should be replaced otherwise we may produce an unresolvable identifier. Is replacing the old name with the new one inside comments really bad idea ? I would expect that if the comment (especially JavaDoc one) references the class' name, the user will expect the IDE to change that too. [reassigned to java module]
> Is replacing the old name with the new one inside comments
> really bad idea ?
Yes. Imagine
/* this class used to be named JarCreater, bad English,
* I renamed it to JarCreator
*/
You see the point
the old name can be referred to from other classes in other packages. Currently it's not possible to chase all references and make them to refer to the new name. Even if this was possible, I'm not sure if it's always a desired behavior. I sometimes intentionally rename a public method and recompile to find out who is using it. In such cases the compile errors are what I want. As for renaming in comments: what if the name is same as a word of natural language which is used in comments in general meaning (e.g. View)? The replacement could be made in the source provided that a) the behaviour would be optional and configurable b) only constructions known to refer to that particular symbol would be replaced Anyway, I'm changing the status to P4-enhancement. Unless we have complete dependency information for _all_ classes in a project, complete replacement is not possible. I'm marking this invalid - until we can manipulate with complete source's model its pointless, anyway. Cool feature *** Issue 24508 has been marked as a duplicate of this issue. *** *** Issue 12966 has been marked as a duplicate of this issue. *** Implemented in refactoring module, in NB4.0 Cool. It took four years to implement, but finally we have it. :) |