• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thursday's cool Eclipse feature of the day

 
Author
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Open one of your java files that defines some class having a number of instance variables. Double click to select one of them (on the declaration or any place it's used, doesn't matter). Press Alt+Shift+R. This invokes the deceptively simple but most common refactoring - rename.
Enter the new name for the field and press OK to rename it or Preview to see what the changes will be before you perform the operation. Eclipse will change the name of *all* occurrences of the field. One rename could result in dozens or hundreds of changes across your project, and it's all undoable.
This is *way* better than a simple text substitution. For example, it's smart enough to not rename fields with the same name in other classes. It won't change the field name if it appears in comments or strings unless you tell it to. And if you have getter/setter functions with standard names, for example if your field is "window" and you have getWindow() and setWindow(), Eclipse will offer to rename those for you too.
Rename works on any Java objects - fields, variables, methods, interfaces, classes, compilation units. packages, you name it. For example if you rename class Foo to class Bar, it will change the Foo.java filename to be Bar.java. If you rename a package to take out a level it will reorganize your directory structure and change all the package and import statements that reference that name. Currently it only works for Java but the CDT developers are working to add support for C/C++ as well.
Not bad for pressing three little keys.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Open one of your java files that defines some class having a number of instance variables. Double click to select one of them (on the declaration or any place it's used, doesn't matter). Press Alt+Shift+R. This invokes the deceptively simple but most common refactoring - rename.
Or you could just press 'Ctrl->1' to enable the Quick fix feature.
Rene
[ July 11, 2003: Message edited by: Rene Larsen ]
 
Ed Burnette
Author
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That activates 'local rename' which links all instances of the object you selected to each other so you can change them all at once. That's a nice feature all its own, but it doesn't affect other files, doesn't have a preview, and is kinda slow for larger files.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic