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.

Bug 7565 - After you rename the node of a form in Explorer, not all occurencies of the name in the source code are replaced.
Summary: After you rename the node of a form in Explorer, not all occurencies of the n...
Status: CLOSED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 4.x
Hardware: All All
: P1 enhancement (vote)
Assignee: issues@java
URL:
Keywords:
: 12966 24508 (view as bug list)
Depends on:
Blocks:
 
Reported: 2000-09-04 10:02 UTC by Antonin Nebuzelsky
Modified: 2007-04-03 18:02 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antonin Nebuzelsky 2000-09-04 10:02:31 UTC
[1086]

To reproduce:

1) Create for example new OK / Cancel dialog from a template and give it the
name "testdialog".
2) Rename the node in the Explorer from "testdialog" to "dlgtest".
3) Almost all occurencies of "testdialog" in the created source code are
replaced by "dlgtest", but
it remains in automatically created comments and also in the body of the method
main!
Comment 1 Tomas Pavek 2000-09-04 13:56:59 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.)
Comment 2 Antonin Nebuzelsky 2000-09-04 14:10:59 UTC
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?
Comment 3 Svata Dedic 2000-09-04 14:29:59 UTC
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.
Comment 4 _ ttran 2000-09-04 14:41:59 UTC
[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
Comment 5 _ ttran 2000-09-04 14:43:59 UTC
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.
Comment 6 Tomas Pavek 2000-09-04 14:56:59 UTC
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)?
Comment 7 Svata Dedic 2000-09-07 12:38:59 UTC
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.
Comment 8 Svata Dedic 2000-10-11 17:23:59 UTC
I'm marking this invalid - until we can manipulate with complete source's model
its pointless, anyway.
Comment 9 Jan Becicka 2002-07-12 09:28:06 UTC
Cool feature
Comment 10 Jan Becicka 2002-08-06 12:34:54 UTC
*** Issue 24508 has been marked as a duplicate of this issue. ***
Comment 11 Jan Becicka 2002-08-06 13:30:05 UTC
*** Issue 12966 has been marked as a duplicate of this issue. ***
Comment 12 psuk 2004-11-02 08:29:45 UTC
Implemented in refactoring module, in NB4.0
Comment 13 Antonin Nebuzelsky 2004-11-02 08:50:22 UTC
Cool. It took four years to implement, but finally we have it. :)