This documents describes refactoring support in NetBeans Ruby.
For this example, we will rename the @comments field in the Rails application controller. Right-click on it, enter a new name and click OK. Next, click "Preview". The bottom window displays a list of refactoring operations, along with diffs for the currently selected item. You can walk through the changes with the Up/Down arrows, and unselect any changes that you do not like before clicking the Refactor button to apply the changes. Click on the image to view full size (both the dialog and the results window are displayed here as an example). In NetBeans, the dialog box will be displayed first. After clicking Preview, the dialog is removed and you will only see the bottom window.
Again, notice how the renaming operation includes changes in .rhtml files. The advantage of this approach over a regular Search/Replace editor operation is that by using parse trees, we have a lot more confidence in the matches. The IDE will not confuse a local variable reference to foo with a method named foo. It does however still have difficulties knowing whether symbols and method names that occur in multiple places refer to say the same method, so at this point it errs on the side of optimism and presents them all as potential uses.
NOTE: The Refactoring menu has an Extract Method item that is always grayed out in Ruby files. This is because that particular action is hardcoded to the Java refactoring for extract method. We will fix that in an upcoming release.
NOTE: The Refactoring menu has an Introduce... item that is always grayed out in Ruby files. This is because that particular action is hardcoded to the Java refactoring for introduce variable. We will fix that in an upcoming release.
Go to the Ruby Hints page for a list of the current quickfixes.
This page was last modified on 5 November 2009, at 15:56.