Saturday, April 21, 2007

Saturday Morning Hack

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


I've heard from a number of people that the ability to jump to a file by type (Open Type), or by filename (Open File) are really important to them. To the point of being adoption blockers.



Both are in the works.



NetBeans has always had a Go To Type for Java (Alt/Ctrl-Shift-O), which we're now retrofitting to become a generic Goto Type facility that other languages can plug into. That means introducing a new API etc. which requires some more effort - so this isn't there for Milestone 9.
However, in the meantime, I've taken the early work on that and hacked it into a Ruby-only module which will let you jump to Ruby types. It's there in the editor context menu (under Go To), bound to a different shortcut. Unlike the general Open Type which will work from any file (or even when you're in a non-source editor window), this will only work from Ruby files. You can get the module
here. That's an NBM file - a netbeans module bundle - which you can install via Tools | Plugins - just switch to the Downloaded tab and point to your NBM. Click Add Plugins. (Sorry, the modules are not signed so you'll get a warning.) It will require a restart. Also, the revamped Plugin Manager is brand new and is stabilizing right now - you may run into some issues. One thing to try is to install one module at a time. You need brand new Ruby bits for this too - go to nbextras.org.



Here's a screenshot of what it looks like (although this includes Java type matches, which the provided hacked module won't do) :






The ability to jump to any file based only on the filename (not the path) is tracked in
issue 44586, and there's been some work happening in a branch. Even though it's not done, you may find it useful in your day to day work. To get it, you can download the module here. Once done, you'll have a Goto File In Project item in your Navigate menu. The operation is faster after the first time.



Finally, I've updated the TextMate snippet importer I recently discussed with some bug fixes - get the latest version here.


12 comments:

  1. Open Type/Resource has been the big thing I've been missing. I feel a bit of a navigational clutz without it. Thanks!

    ReplyDelete
  2. Wow -- thanks so much for this weekend effort!

    ReplyDelete
  3. Got it working -- looks good. Thought you should know, it seems an exact match search doesn't quite work. If I type "Person" I get no results, but "Perso*" yields the correct list, including the Person class. Additionally, I think an implicit * should be at the end of your search, so if I just type "Per" I should get everything starting with Per. Thanks again, this makes the navigation usable now!

    ReplyDelete
  4. Oddly, after an OS X update, it works as I expected. Nevermind! :)

    ReplyDelete
  5. Great, glad to hear it! By the way, the Go To File functionality has had a few more fixes to it, and they've set up a continuous build where you can grab the latest: http://deadlock.nbextras.org/hudson/job/go%20to%20file/

    ReplyDelete
  6. Excellent, I was missing this one that much! So much nice stuff done the past weeks!
    I really need to update my charts about Ruby/Rails IDE!!

    ReplyDelete
  7. Sorry to rain on the parade, but that behavior I mentioned above is still happening. Sometimes the thing works as expected, sometimes it ignores the last character and doesn't inject a * at the end implicitly. Sounds like a one off error to me in the code that's taking the expression from the user :)

    ReplyDelete
  8. Hello:
    I am using nb M9/jruby. When I use it to edit
    a plain text file, the simple indentation engine does
    not work. For example, if you try to use nb to edit
    a haml file (file.haml), it would not auto indent. I know it is not exactly what you are working on but any quick help would be great.
    To reproduce, just open an plain empty file (that does not belong to any known category) from any project
    and try to edit it to see if it autoindent.

    ReplyDelete
  9. Hi, I found a remedy in nb help that partially resolve this issue. I added the extension to a
    know file object type (xml) and the indentation works. But this is not ideal as I would prefer
    to have a plain text file editor with indentation
    feature along without all the xml editor feature.

    ReplyDelete
  10. Wishlist:
    1. support for haml template editing
    2. each ruby/rail project can set its own
    Ruby installtion path (forexampe, one project
    could use CRuby and others use Jruby) instead of
    using global setting.

    ReplyDelete
  11. The latest milestone is out - Tor the Ruby installation on Mac it seems you need the full 152MB install - is the cutdown version of Netbeans available just for Ruby? (or is this not recommended)

    ReplyDelete
  12. Hi Greg,
    Hope I can help. Works fine for me using the slimline netbeans-6.0m9-basic-macosx-x86.tgz, with config in (~me/).netbeans/6.0m9



    I use a config file in etc, to point elsewhere for the ruby1 cluster, but putting the cluster in there should work fine too.

    ReplyDelete