Tuesday June 05, 2007
As of this evening there are two new features in the builds: Find Usages, and Rename. Let's start with Find Usages. Right click on a symbol and choose "Find Usages" (or use the keyboard shortcut). Let's say I search for the usages of the UserMail class in the Mephisto Rails blogging application (click for full size):
This feature also knows about .rhtml and .erb files - it parses the embedded Ruby and analyzes it. Here's an example where I've searched for the usages of a @comments field in a controller - notice the .rhtml matches:
(Sorry, I know these images might be a bit large on some screens; I should have taken the screenshots at a smaller screen resolution than my usual 1680x1050.)
In the Find usages dialog I can also ask NetBeans to find subtypes of the class rather than usages. Here's an example of what I get if I search for subclasses of the ApplicationController class:
Next, Rename refactoring. Let's say that I want to rename the @comments field in my Rails application controller. I right click on it, choose a new name and hit OK. I then click "Preview", and in the bottom window I get a list of refactoring operations, along with diffs for the currently selected item. I can (and should!) walk through the changes with the Up/Down arrows, and I can unselect any changes that I don't like before I click the Refactor button to apply the changes. Click on the image for full size (I'm showing both the dialog and the results window here; in reality you'd first get the dialog, and when you hit Preview it disappears and you 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.
WARNING: This feature is definitely preliminary!! Hopefully the bold red warning in both the Rename and Find Usages dialog makes this really clear. The Refactor button will be disabled and Preview required shortly.
However, this feature should be improving rapidly as I get feedback and implement some more things on my todo-list. Find Usages at least should be quite useful as a navigation tool. If you're going to use the Rename feature, please make a backup of your code first!
(This feature requires the very latest builds - try the Ruby IDE from nbextras.org, or for fuller instructions, see the wiki page. Auto updating from M9 isn't working any more because I'm relying on private APIs that have changed incompatibly.)
P.S. A great big thank you to all of you who have tried the NetBeans Ruby support, and especially to those of you who have provided feedback!
(2007-06-05 19:48:27.0) Permalink Comments [32]
Posted by hemant kumar on June 05, 2007 at 11:01 PM PDT #
Posted by Dushyanth Tiwari on June 06, 2007 at 06:31 AM PDT #
Posted by Greg on June 06, 2007 at 10:20 AM PDT #
Refactoring support is looking great...looking forward to having some time to test/play. Cheers GregH
Posted by GregH on June 06, 2007 at 01:19 PM PDT #
Posted by Tim on June 06, 2007 at 01:48 PM PDT #
Posted by freeman on June 06, 2007 at 06:52 PM PDT #
Posted by Decklane on June 08, 2007 at 04:20 AM PDT #
Posted by JohnH on June 08, 2007 at 02:02 PM PDT #
Posted by Dave on June 08, 2007 at 02:42 PM PDT #
Dushyanth - it's both. This is not some conspiracy to try to get Ruby developers to come to a Java IDE and maybe switch to Java. Instead, NetBeans is branching out as a tool and supporting other languages. (We've already had a C++ IDE for Solaris based on it so it's not really true that it's been just a Java IDE, but that's how a lot of people think of it). Sun is doing this because we want to have solutions people are looking for. Ruby runs very well on a big Solaris server... certainly better than ASP.NET :-)
Hi Greg (sorry about the comment spam trouble - the spam filter seems a bit overly aggressive, but it's a sitewide thing I have no control over). Somebody is looking into the posibility of including these snippets in the product by default, which would be a better solution than bundling an importer. I'll ping them and see how it's proceeding.
Freeman, I dont know of a way to change the help window font. But one thing I could do which might be nice is add a property which lets you specify your own stylesheet to be used for that HTML area. I'll post something here when I get that done.
JohnH, DRYML looks interesting. Of course there are also requests for other additional languages, like HAML. It's hard to know how to prioritize this work :) DRYML however looks very ERB/RHTML-like. Perhaps we can get pretty far by just assigning a flavor of RHTML-treatment to .dryml files?
Posted by Tor Norbye's Weblog on June 09, 2007 at 07:56 AM PDT #
Perhaps downloading Niko's bundle from subversion will give you all that's needed to have it going in just a few minutes?
Posted by JohnH on June 09, 2007 at 08:57 AM PDT #
Posted by Tor Norbye's Weblog on June 09, 2007 at 12:54 PM PDT #
Posted by Stephen Molitor on June 10, 2007 at 08:32 AM PDT #
Posted by Tor Norbye's Weblog on June 10, 2007 at 03:09 PM PDT #
Posted by Stephen Molitor on June 10, 2007 at 05:36 PM PDT #
Posted by Tor Norbye's Weblog on June 10, 2007 at 07:05 PM PDT #
Posted by freeman on June 10, 2007 at 09:47 PM PDT #
Posted by freeman on June 12, 2007 at 02:19 AM PDT #
Try a very recent build, and please let me know if it's still not working and I'll pass the word on.
Posted by Tor Norbye's Weblog on June 12, 2007 at 06:51 AM PDT #
Posted by Jerrett on June 12, 2007 at 12:21 PM PDT #
Posted by Tor Norbye's Weblog on June 12, 2007 at 01:11 PM PDT #
Posted by tom fowler on June 12, 2007 at 06:36 PM PDT #
Posted by freeman on June 12, 2007 at 06:54 PM PDT #
Posted by Stephen Molitor on June 13, 2007 at 08:43 AM PDT #
IMPORT SUMMARY ------------------------------ Binary plist files! Your snippets are in a binary plist format. To be imported, they must be in XML format. First make a backup of your bundle tree (zip -r bundle.zip whatever.bundle) and then run "plutil -convert xml1 snippet.plist" to convert each file. To perform this for a directory tree, use this: find . -name "*.plist" -exec plutil -convert xml1 {} \; (To change back, replace -convert xml1 with -convert binary1 Imported 0 snippets. Skipped 0 snippets.By the way, we're still looking into bundling a lot of these with the product so you won't need to import if you're just using the builtins.Posted by Tor Norbye's Weblog on June 13, 2007 at 01:57 PM PDT #
Posted by tom fowler on June 13, 2007 at 03:57 PM PDT #
Posted by Stephen Molitor on June 13, 2007 at 06:50 PM PDT #
Regarding Rails console - I just took a stab at implementing it - and I integrated in disabled form because of a blocking bug in the output window (106741). Hopefully somebody will evaluate it quickly.
Posted by Tor Norbye on June 14, 2007 at 08:59 PM PDT #
Posted by Jan Wikholm on June 15, 2007 at 12:58 AM PDT #
Posted by JohnH on June 15, 2007 at 12:44 PM PDT #
Posted by Mark Allerton on June 15, 2007 at 11:08 PM PDT #
Posted by tom fowler on June 19, 2007 at 01:03 PM PDT #