« Ruby Screenshot of... | Main | Progress »

20070620 Wednesday June 20, 2007

Ruby Screenshot of the Week #14: RHTML

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.

(2007-06-20 09:40:09.0) Permalink Comments [45]

Comments:

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.

Posted by Matt Lins on June 20, 2007 at 10:10 AM PDT #

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 ?

Posted by hemant kumar on June 20, 2007 at 11:28 AM PDT #

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

Posted by Steve Molitor on June 20, 2007 at 02:31 PM PDT #

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

Posted by doug livesey on June 21, 2007 at 12:36 AM PDT #

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

Posted by Jerrett on June 21, 2007 at 09:40 AM PDT #

I second the auto-completion inside of markaby files!

Posted by Dan on June 21, 2007 at 09:45 AM PDT #

Thanks for your feedback everyone!

Hemant, sorry, it's not implemented yet... but I think fixing goto-declaration for render to handle render and redirect falls under the umbrella of bugfixing so can still be done for 6.0, time permitting.

Steve, the best way to submit bug reports is using the netbeans issue tracker. That ensures that your feedback won't get lost and you get notified when it's integrated etc. (Plus if I need followup information I know where to go rather than try to locate the feedback in past blog entries, direct e-mail, other people's blogs etc. :) I have a summary of the feedback options here: http://wiki.netbeans.org/wiki/view/RubyFeedback.

Jerrett and Dan, since we're after feature freeze, can you rephrase that as a bug report please ? ;-) Seriously though, since I already support .mab files, having them reflect ActionView context is arguably a bug fix. It will have to wait until after M10 since we're only fixing showstoppers right now though. Hopefully in a dev build in a week or two.

Posted by Tor Norbye on June 21, 2007 at 10:34 AM PDT #

really beautiful job.

Posted by p-daddy on June 21, 2007 at 01:29 PM PDT #

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

Posted by Steve Molitor on June 22, 2007 at 10:34 AM PDT #

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!

Posted by Dan on June 22, 2007 at 10:58 AM PDT #

Hi Tor! Thank you for your great work. Your team additions to netbeans ide really rocks!

I have a few questions:

  • Is it possible to enable the colorization of the server output? I'm using the windows port and the output window does not understand the control characters, so instead of color i'm getting a lot har to read things on the output window.
  • Have you considered adding a log tail? It is really usefull to have one to see how the log gets filled.
  • General question: Is this realted to jruby? Is sun officially sponsoring this project? I know these may sound as a silly questions, is just that i don't fully understand sun's position related to your project and also about jruby. May be you can point me to some pages explaining it.
  • Thank you very much!!!

    Posted by Emmanuel Oga on June 22, 2007 at 12:49 PM PDT #

Jerret and Dan, try build 2395 or later and see if the .mab stuff works for you.

Steve, four hours of indexing time is really abnormal, unless you have some really giant gems in your application. (Where is it spending its time? In vendor/ in your rails app or do you know more specifically what it's working on? Any errors in the log?) More likely there's something pathological in your index which makes merging really slow. Try just exiting, deleting the "var/cache/gsf-index/" part of your user directory; anything in var/cache can be deleted - there's no configuration there, everything will be recreated, and then restart. I've seen some warnings about multiple entries in the index so I'm going to have to look into that some more.

I'm not aware of a way to single-click to open files. I've gotten several requests for "test current method" so I'll definitely to do that. A green-bar thingy would be great too. So many things to do, so little time :)

Emmanuel, I'd like to colorize the output but it's not possible today (the I/O window isn't doing proper terminal emulation, and there's no way to set colors there - it just has builtin hyperlink coloration. I've requested this so hopefully it can be enhanced and I'll take advantage of it.)

This is related to JRuby in the sense that it's using JRuby (for parsing to do the semantic editing features), and it supports JRuby usage. But it doesn't require JRuby usage; NetBeans should also be a great Ruby IDE for developers who want to write pure Ruby applications. Sun is officially sponsoring this; lots of full time Sun engineers (me included) work on NetBeans, and Sun hired several JRuby core developers as well.

Posted by 75.48.78.241 on June 22, 2007 at 03:50 PM PDT #

Jerret and Dan, try build 2395 or later and see if the .mab stuff works for you.

Steve, four hours of indexing time is really abnormal, unless you have some really giant gems in your application. (Where is it spending its time? In vendor/ in your rails app or do you know more specifically what it's working on? Any errors in the log?) More likely there's something pathological in your index which makes merging really slow. Try just exiting, deleting the "var/cache/gsf-index/" part of your user directory; anything in var/cache can be deleted - there's no configuration there, everything will be recreated, and then restart. I've seen some warnings about multiple entries in the index so I'm going to have to look into that some more.

I'm not aware of a way to single-click to open files. I've gotten several requests for "test current method" so I'll definitely to do that. A green-bar thingy would be great too. So many things to do, so little time :)

Emmanuel, I'd like to colorize the output but it's not possible today (the I/O window isn't doing proper terminal emulation, and there's no way to set colors there - it just has builtin hyperlink coloration. I've requested this so hopefully it can be enhanced and I'll take advantage of it.)

This is related to JRuby in the sense that it's using JRuby (for parsing to do the semantic editing features), and it supports JRuby usage. But it doesn't require JRuby usage; NetBeans should also be a great Ruby IDE for developers who want to write pure Ruby applications. Sun is officially sponsoring this; lots of full time Sun engineers (me included) work on NetBeans, and Sun hired several JRuby core developers as well.

Posted by Tor Norbye on June 22, 2007 at 03:50 PM PDT #

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

Posted by addam on June 23, 2007 at 03:50 AM PDT #

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

Posted by Tor Norbye on June 23, 2007 at 08:38 AM PDT #

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.

Posted by Dan Baxter on June 23, 2007 at 01:55 PM PDT #

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.

Posted by Steve Molitor on June 23, 2007 at 09:09 PM PDT #

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

Posted by Steve Molitor on June 23, 2007 at 09:10 PM PDT #

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?

Posted by Stephen Molitor on June 24, 2007 at 09:16 AM PDT #

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.

Posted by Klaasjan Tukker on June 25, 2007 at 11:12 AM PDT #

Dan, yes, RHTML formatting will be added. It just didn't make it for M10. It should appear in trunk builds in the next week or two.

Steve, I don't know why bold doesn't work for the Monaco font; I see the same behavior on my Mac. It works for other fonts... Perhaps a OSX JVM issue? I downloaded JEdit and changed the font there - it's the same issue; choosing Bold for Monaco has no visual effect, so I it's probably a VM issue.

There's no way to filter out the vendor directory at the moment. However, I'm planning on changing things a bit such that vendor and lib no longer show up in the project view (but still are used for source indexing etc.).

I'm not sure what the code template issue is. Are you using the extra CodeTemplates module, or just the built in code template support in the Preferences panel? (Editor -> Code Templates). The latter work for me. (The optional module may need some work to reflect recent changes in the code template infrastructure).

Klaasjan, thanks for the pointer!

Posted by Tor Norbye on June 25, 2007 at 11:51 AM PDT #

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.

Posted by James Moore on June 25, 2007 at 12:13 PM PDT #

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.

Posted by Tor Norbye on June 25, 2007 at 12:27 PM PDT #

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.)

Posted by James Moore on June 25, 2007 at 12:59 PM PDT #

One more thing:

When you are editing your Controller actions, if you press ctrl+shift+a to go to the proper view, nothing happens if you don't have one created.

It will be very nice and usefull if the ide would ask me if i wan't to create that view.

Thanks again! Emmanuel.

Posted by Emmanuel Oga on June 25, 2007 at 01:26 PM PDT #

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.)

Posted by 70.43.126.249 on June 25, 2007 at 01:33 PM PDT #

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?).

Posted by 70.43.126.249 on June 25, 2007 at 02:00 PM PDT #

'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

Posted by Steve Molitor on June 25, 2007 at 03:33 PM PDT #

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.

Posted by 70.43.126.249 on June 25, 2007 at 05:49 PM PDT #

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?

Posted by Gili on June 25, 2007 at 09:51 PM PDT #

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

Posted by Warren Wessels on June 26, 2007 at 12:13 PM PDT #

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"

Posted by freeman on June 26, 2007 at 06:58 PM PDT #

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

Posted by Shadowfiend on June 27, 2007 at 08:35 AM PDT #

Regarding code templates that pop up a dialog to request parameter values: No, there's no way to do that today. Perhaps we could add it. Can you give some specific examples of how you would use this? The way code templates work today in NetBeans is that they don't only have tabstops, they also have parameters being evaluated and edited on the fly. I can't think of an example where having a dialog box first would be more usable than editing the parameters in place, unless the point is that the stuff you type into the dialog is radically different than what gets inserted into the document?

Regarding hyperlinks not working: Can you e-mail me - tor.norbye@sun.com (or file a bug) with the exact output that wasn't hyperlinked? That way I can check what the problem is with the path recognizer (and add a unit test for it). I did fix some bugs in this area yesterday but there may be more.

Steve, I see the problem with smart selection keybindings myself. I'll look into it.

Gili, thanks - I'll forward your feedback to the team looking at keybindings and other defaults.

Warren, the issue with the IDE restarting itself is a bug in the startup script related to Auto Update (the startup script cooperates with Auto Update when Auto Update is used to restart the IDE). I seem to remember that it's Mac specific, but in any case, it's being fixed. Just ctrl-c out of the restarted IDE for now.

Freeman, thanks for the suggestion; it's a good time to bring it up since I'm looking into formatter bugs right now. But as Shadowfiend pointed out, all examples I'm coming across in the Ruby libraries seem to indent when at the same level as case (and else and end). When I get to the Pretty Printer and more detailed formatting options I'll try to remember to add an option for this.

Posted by Tor Norbye on June 27, 2007 at 12:53 PM PDT #

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.

Posted by Steve Molitor on June 27, 2007 at 02:10 PM PDT #

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

Posted by Warren Wessels on June 27, 2007 at 02:20 PM PDT #

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

Posted by freeman on June 27, 2007 at 06:19 PM PDT #

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.

Posted by James Moore on June 29, 2007 at 09:00 AM PDT #

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

Posted by hemant kumar on June 30, 2007 at 04:40 AM PDT #

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

Posted by Matt Verran on July 02, 2007 at 07:53 AM PDT #

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

Posted by freeman on July 03, 2007 at 06:16 PM PDT #

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.

Posted by hemant kumar on July 04, 2007 at 12:05 PM PDT #

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.

Posted by James Moore on July 04, 2007 at 06:07 PM PDT #

Thanks for your feedback everyone. Sorry about the delay, I've just taken a couple of days vacation.

Hemant, I didn't know there was a problem with YAML editing; if you can file a report with details to reproduce and platform info, that would be great. (It works for me so some more details would help.).

Regarding RHTML editing performance: Do you have JavaScript embedded in your files? In that case it's probably issue 108874. There are some other high priority bugs in this area too - issue 105423, issue 106547, issue 108889, and <a href="http://languages.netbeans.org/issues/show_bug.cgi?id=108813">issue 108813 .

I have evaluated these, but they are in other areas than the Ruby support so I can't easily fix them myself. But I will try to push for a speedier resolution.

Now some quick responses to the other ideas:

  • Freeman, yes, I'll make sure the Migrate menu handles lots of items better.
  • James, yes, we definitely need to support Subversion better on Windows. There are plans to use a Java library for subversion support rather than relying on subversion binaries; my understanding is that we had license incompatibilities earlier and that these have recently been resolved.
  • Matt, it would be nice to support visual design of web pages, and I plan to look at it, but it won't be for 6.0. The plan now is to try to stabilize what we have such that 6.0 is solid and can be used for day to day work before working on big new features.

Posted by Tor Norbye on July 06, 2007 at 09:54 AM PDT #

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.

Posted by hemant kumar on July 09, 2007 at 02:46 AM PDT #

Post a Comment:

Comments are closed for this entry.