Wednesday, June 20, 2007

Ruby Screenshot of the Week #14: RHTML

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.


Phew - it's been a very busy past couple of weeks. We had feature freeze for NetBeans 6 just a couple of days ago (Friday night at midnight to be exact) so I was focusing all my energy on getting as many things done as possible by the deadline. From here on out, focus will be on stability. I'm starting to work my way through the bug list, and it's looking promising.



The feature I'd like to show this time is a recent addition: Improved RHTML support. In particular, RHTML completion, RHTML goto declaration, and displaying Ruby errors in RHTML files.



Here's RHTML completion (click for full size):








Things to notice here is that first of all, the various methods you might want completion (and more importantly, documentation) for that are coming from ActionView are showing up as expected - link_to, form_tag, and so on. In addition, methods from your Helper class for this controller also show up. There's also an inherited attribute from ActionView here.



Second, note the enhanced display of the rdoc. It turns out lots of Rails documentation have code snippets, and the colorizer (which I
discussed recently) now properly handles language embedding too - RHTML fragments containing Ruby and HTML colors.) Speaking of colors, NetBeans 6 recently got a makeover in the default color scheme. In addition, there are some new color themes available in the options dialog - including the old colors. You can see the new colors in these screenshots.



Go To Declaration is pretty self explanatory - it works the same way that it does in Ruby files; hold the Ctrl-key and click on identifiers and it will warp to the definition for that method, class or variable assignment. Another new feature is displaying source errors in the file. Behind the scenes, NetBeans now models what ERB will do to the file in a Rails server, and maps these errors back to the RHTML source. Thus, if you have an error like the below, you get an error annotation with a tooltip displaying the error:






One thing which is still missing is indentation of the Ruby code in RHTML files. Marek Fukala is working on this for all the embedded languages, and I believe this feature is still going in after the freeze, so look for it in upcoming builds.



Finally, thanks to those of you who have been using the regular builds and providing feedback and bug reports. I apologize for the last couple of weeks - because of the heavy feature focus before the deadline I haven't been very responsive, and the builds have gone through a huge amount of flux. One of the things which is going on is that all the keyboard shortcuts have been changing - the details are outlined here - so if you thought something was broken, perhaps it's just using a different shortcut now. (We're still tweaking this.) Things will get more and more stable from day to day now. Milestone 10 should be out in a couple of weeks.


37 comments:

  1. Tor,
    I've been using this pretty regular for about a month. It's really been working great! It's now my choice for RoR/Ruby Development.
    I appreciate the quick bug fixes in the early builds and the conversations via email.
    Thanks.

    ReplyDelete
  2. Hmm good work tor, thanks a ton.
    I still feel that, we should have goto controller/view/tests/stylesheets/javascripts/migrations/config actions like the way emacs/textmate has.
    Also, did you consider my feature request regarding following render :partial and redirect_to ?

    ReplyDelete
  3. Tor,
    What's the best way to submit bug reports?
    Thanks.
    Steve

    ReplyDelete
  4. Hi -- just to let you know that since trying Netbeans 6 (M9) for Ruby & RoR develpoment, I've stuck with it.
    Fantastic work!

    ReplyDelete
  5. Can we get ActionView autocomplete stuff in markaby files too? :)

    ReplyDelete
  6. I second the auto-completion inside of markaby files!

    ReplyDelete
  7. really beautiful job.

    ReplyDelete
  8. I have a few quick questions:
    1. Previously it seemed that the indexing time went way down. However on the new builds it seems to take much longer to do the initial indexing -- over 4 hours on my machine. Did something regress?
    2. Is there a setting to allow single-clicking to open a file from the project or file view, instead of double-clicking?
    3. Is there a way to run just one test in a unit test?
    4. Will there be purty JUnit style interface with a green bar and everything? I love my green bars!
    Steve

    ReplyDelete
  9. Steve Molitor: Are you using the bundled jruby or did you change interpreters? I seem to remember Tor saying that he's pre-indexed the bundled version of jruby as well as the most recent version of rails at the time. I'm using the normal Ruby interpreter and my indexing time is a little longer, but not four hours!

    ReplyDelete
  10. Thanks for this great job !!!! I just switched to ruby netbeans .... so far it's great !!
    The only thing I miss of radrails is the rails console.
    Will it be available in the future version ?
    Cheers,
    Addam

    ReplyDelete
  11. I recently added a Rails console; look for it in the context menu for the project.

    ReplyDelete
  12. Is there any plans to add a code reformat feature for RHTML files? It's one of the things I actually liked about RadRails. Thanks.

    ReplyDelete
  13. Silly question: Does anyone know how to get bold working with the Monaco font on macs in netbeans? I like the monaco font (it's what textmate uses), but for some reason bolding doesn't work with netbeans if I select monaco as te default font.

    ReplyDelete
  14. One more: Is there a way to exclude certain sub-directories from a Rails project? I'd like to exclude my vendor directory.

    ReplyDelete
  15. Is there a trick to creating new code templates? I am able to modify and save existing ones, but I can't add a new one. If I try, it doesn't work when I try to tab expand it, and when I exit and restart NetBeans my new template is gone from the list of templates.
    Is this a bug or am I missing something?

    ReplyDelete
  16. Emmanuel: with regards to a "tail module" have look at: http://roguexz.googlepages.com/netbeans
    you can find the module there and install it via his update-center.

    ReplyDelete
  17. Is there a mailing list or a forum somewhere for Ruby Netbeans? Seems like blog comments are being used for that purpose, but it's pretty awkward.

    ReplyDelete
  18. Yes - see http://wiki.netbeans.org/wiki/view/RubyFeedback. I'm also responding to feedback here; I'll take any feedback I can get, including from people who don't want to subscribe to NetBeans aliases (none of the aliases accept posts from non-subscribers as a spam-prevention approach.) Using issuezilla to file bug requests is the best way to go about it since those issues won't get lost, and you get notified when they're addressed, plus there's an easy way to indicate priorities etc. However, I don't want the overhead to prevent anyone from providing feedback which is why I'm trying to address other forms of feedback as well.

    ReplyDelete
  19. You may want to edit that page and point out to people that dev@scripting.netbeans.org is used for Ruby issues. That's not going to be obvious to people who object to calling dynamic languages "scripting" languages.
    (I read that page, specifically looking for a reference to a mailing list, and it didn't register with me that dev@scripting.netbeans.org could be for Ruby on NetBeans issues - given the name, it obviously couldn't be for Ruby discussions. Shows you how much I've internalized the "only Java zealots call Ruby a scripting language" rule.)

    ReplyDelete
  20. OK, adding code templates is working fine for me now that I downloaded the latest build.
    Is there any way to write code templates that prompt for input? A lot of TextMate's snippets do that. It makes it easier to remember the abbreviations, as one abbreviation will trigger a dialog box with several options. (The cost of course is having to type a bit more.)

    ReplyDelete
  21. Is there a 'run last launched' or similar action? It's nice to have a hot key to re-run the last test you've ran, even if you're in a different file (usually the source file).
    Also I'm not sure the error parsing is working properly when running unit tests. If I get a unit test failure, clicking on the error line in the output window doesn't usually take me to the error. It might be because the text often ends in "foo.rb]" and the bracket is throwing the hyperlinking off? If I get an error with a stack trace, I can usually click on the different sources listed in the trace, except sometimes the last one (again I think it has the bracket?).

    ReplyDelete
  22. 'Smart selection' isn't working for me anymore on my Mac. It seems that control-shift-up/down arrow is bound to 'move selection else line up/down'. However removing those key bindings doesn't seem to help. Command shift up/down arrow doesn't work either

    ReplyDelete
  23. Scratch what I said about navigation to errors. I think the problem is relative versus full paths. If ruby spits out file names with full paths the error links work, but not when it spits out relative paths.

    ReplyDelete
  24. The new keyboard shortcuts are a huge pain in the ass. I can't figure out how to navigate to the next/previous editor tab and I totally disagree that alt+arrow should bind to "navigate back/forward". Are you honestly telling me people use that feature more often than previous/next tab? I highly doubt it! :)
    Any idea on what the new keyboard shortcut is?

    ReplyDelete
  25. Excellent so far... I've been really enjoying the coding experience in NBRubyIDE... Brilliant!
    One weird thing: When I shut down the IDE, it sometimes starts itself back up again... any ideas from anyone why this would happen? I am running build 2464 right now, of the unzip-and-play IDE download from hudson.
    Thanks!
    Warren

    ReplyDelete
  26. Hi Tor! The small issue - in the "case..when..end" structure i think it would be better to indent "when" rather that to have it on the same level as "case"

    ReplyDelete
  27. freeman -- it seems to be the norm in the Ruby community to indent `case', `when', and `end' at the same level.

    ReplyDelete
  28. Tor,
    I think I described the 'dialog box' thing wrong. Here's an example. In TextMate, when you tab complete the abbreviation 'mcol' in a migration, a selection box pops up with different code template options:
    1. Add Column
    2. Rename Column
    3. Add / Remove Column
    4. Rename / Rename Column
    5. Remove Column
    6. Remove / Add Column
    You pick your choice and then the appropriate snippet executes. You could accomplish the same thing with 6 different abbreviations for each discrete template, but that's more abbreviations to remember.
    It's really not a big deal but right now when you type 'mcol' in NetBeans you only get the 'add column' template; there are not templates for the other 5 options. So maybe we can just add more templates.

    ReplyDelete
  29. Thanks, Tor... will do... this is looking better and better!

    ReplyDelete
  30. Hi, Tor! Another small thing that need to be improved - if there is a lot of migrations in the project I cannot see and select the latest ones in the popup menu "Migrate Database" - i think it would be better to divide migrations in several columns or to add the scroller

    ReplyDelete
  31. Anyone else trying to use NetBeans subversion support on windows? So far, it's been a fairly unpleasant experience. On the positive side, the dev guys respond to bug reports pretty quickly (http://www.netbeans.org/issues/show_bug.cgi?id=108069).



    On the negative side, I have yet to be able to get subversion to work. And the user experience is terrible, even if I could get it working.



    * Fails mysteriously with cygwin's svn in the path
    * doesn't seem to recognize an explicitly set svn binary through the options window

    * NetBeans just hangs when non-cygwin svn.exe is in the path and I do 'show changes'

    * Relies on yet another external utility, plink, to do svn+ssh



    Compare this to the experience on Eclipse, where things just work as long as you use their native java subversion support. No messing around with external utilities - external utilities are the kiss of death for Windows.

    ReplyDelete
  32. Did anyone observed Netbeans crawling when editing RHTML files.For me, when I have serveral rhtml views open, IDE crawls.

    ReplyDelete
  33. Great work on bringing Ruby into NetBeans - what are the chances of adding Visual Web Pack style features to Ruby?

    ReplyDelete
  34. Hemant, I also saw something like you describe in RHTML, and also during code templation - NetBeans begins to work very slowly, and shows the strings incorrectly

    ReplyDelete
  35. Ok I am kinda getting tired of this. I think YAML file editing is totally broken with latest version of netbeans.
    Also there are lots of issues associated with rhtml editing and strings getting all screwed up as freeman mentioned.
    I am observing changelogs but nobody seem to have noticed it.

    ReplyDelete
  36. The NetBeans team has been great lately about investigating bug reports - you might want to use http://scripting.netbeans.org/issues/enter_bug.cgi?component=ruby to report any problems you're seeing.

    ReplyDelete
  37. Tor,
    here is description of a problem, when editing YAML or RHTML files.
    Although I can open the file and typing some characters inserts those chars in the editor, but i can't move the cursor at all. However I can move the cursor with mouse. Delete and backspace keys doesn't work, and neither do cursor movement keys.
    But the problem is, i get this problem quite often, but yet I cant point to one thing that makes editor go into this frenzy thing. It isn't used to the case, but happended with latest hudson releases and problem persists across various new releases. It makes rhtml and yaml editing a real pain. I can't yet be sure, how can i reproduce this.

    ReplyDelete