"Philip Miller" <[EMAIL PROTECTED]> writes:

> One refactoring method I would LOVE to be able to do with JDE is
> rename method/class/package.  Often in the middle of development, I
> find a name that is more appropriate than the name I am using and I
> would like to rename it---methods, classes, packages, even public
> static final variables.  (I can do private variables, myself easily
> enough with search and replace! :-) Is there a way to get JDE
> (and/or tags) to help me with renaming?  (If the answer is tags,
> could you please explain how?  I have used emacs for years, but have
> never mastered tags.)

A short crash example: Lets pretend your top Java directory is 

        ~/source/my_java_project

and that you like to change the class name DontGrokTags to GrokTags.
Please do the following:

    M-! cd ~/source/my_java_project; find . -name "*.java" -print | etags - RET
    M-x select-tags-table RET ~/source/my_java_project RET
    M-x tags-query-replace RET \<DontGrokTags\> RET GrokTags RET

... and answer as you please, just like for query-replace (M-%),
i.e. do a couple of "y" until that you are confident that the changes
done are correct, then "!" to do the rest of the files.  End with a
"C-x s" to save all those changed files.

Explanation: 

    o The first line above does a shell command where you run the
      external program "etags" in a nifty "find" command (taken from
      the info pages), to make a TAGS file, situated at your top Java
      directory.

    o The second line tells emacs to use that particullar TAGS file
      for further tags command.  

    o The third line does the magic name change.  Note: I recommend to
      use the regexp meta characters "start of word" (\<) and "end of
      word" (\>) to avoid conversion of other names that use
      DontGrokTags as part of their names, e.g. DontGrokTagsAtAll will
      not be converted by the above method.

The final thing todo is to change the filename DontGrokTags.java.  You
may want to do "M-x vc-rename-file RET ... RET" if your file is under
CVS/RCS control.

Read more about tags in info by doing "C-h i g (emacs)Tags RET", and
more about regexps and searching in "C-h i g (emacs)Search RET".

        Affi

Reply via email to