Ruby Screenshot of the Week #30: New YAML Editor


As part of our Ruby and Rails support, we've had a YAML editor in NetBeans for a couple of releases now. However, the support was primitive. Only the most basic editing features were there, and more problematically, many common, valid YAML constructs were not supported. You'd get various wrong error messages from the parser if you tried to go outside the normal simple syntax of the database.yml file in Rails.



In the latest dev builds however, there's a brand new implementation of a YAML editor. Let's start with a screenshot:







There are several things going on here. First, note that the editor now understands more complicated YAML constructs - such as the << key mapping merge operator. In this file, we've shared the definition of the "createdon" attribute. And in the navigator, as we drill down you can see this attribute showing up properly inlined in both places the reference was used.



Notice also how we have embedded Ruby code here (the green fragment inside <% %>). This is pretty important for another Rails usage of YAML: Fixtures. Just like in ERb/RHTML files, the YAML Ruby embedding support should be complete; quickfixes should work, go to declaration, smart indent and formatting, and so on - including code completion:









Finally, if you're a bit rusty on YAML and can't remember all the various escapes to do collections, aliases, documents, tags and so on, you can invoke normal code completion to see the various special characters - along with the YAML quick reference document in the documentation popup:







There are a few other things in there as well; AST based selection (Command-Shift-Dot or Comma), slightly better smart indent, and so on. One thing which is still missing is code folding. I disabled it since there were a few issues with it still.



I have to pause here and add a big Thank You to Ola Bini from the JRuby team! A few weeks ago, yet another bug report was filed by somebody complaining about a false error in the YAML support, and I decided to look into rewriting it from scratch using the same editor infrastructure that we have for Ruby, JavaScript, etc. The first thing I would need however is a YAML parser. I know JRuby had a good one, so I tried using it - but realized I would need to customize it a bit for IDE purposes. For example, I would need AST offset information. I thought of ways I could subclass parts of the YAML parser to achieve this, and I sent an e-mail to Ola asking if he thought this was feasible. I immediately got a response - and not only did he say it was possible, he offered to personally do it, by adding proper offset support into the parser. And just a couple of days later he released a new version of the parser with full offset support. It worked perfectly. With the parser in hand, implementing the above editing functionality was easy. So a lot of the credit for the new editor goes to Ola. Thank you!



As always with new functionality, please take it for a spin and report back any issues you find (using the normal feedback channels). NOTE - you do need the latest dev builds for this - even 6.5 Milestone 1 is too old. Some of this was checked in today so won't even be in the current nightly build (depending on when you read this).

Comments:

I believe the Aerosmith song with the lyrics "Lovin every minute of it" fits well with this news. Keep rockin the Netbeans Ruby IDE house. Woof woof woof! :)

Posted by Chess on July 06, 2008 at 11:23 PM PDT #

yay! You've made one guy very happy...thanks for the fix, Tor. I'll update my site to reflect the new YAML editor.

Posted by Jacek Furmankiewicz on July 07, 2008 at 12:43 AM PDT #

Yeah that's one more file type I do not need vi for, but this would be even more better if YAML support could be used without "Ruby And Rails" plugin (for us mere mortals using YAML with nbpython for example) - shouldn't it be part of gsf cluster?

Posted by Sven Reimers on July 07, 2008 at 05:05 AM PDT #

Good day, Tor! Another small issue - I cannot set the indent for haml for 2 spaces - it does 4 spaces instead

Posted by ruby.freeman on July 13, 2008 at 11:50 AM PDT #

Hi again! In the latest version the indentation for haml is fixed, but netbeans cannot open an existing project

Posted by ruby.freeman on July 14, 2008 at 09:40 AM PDT #

Hi Sven,
The YAML editor is tied to the Ruby cluster right now because it's using the YAML parser from JRuby (as well as some other supporting libraries like the bytelist jar). But it sounds like I'll need to make it separate. The Google App engine for example uses YAML and Python, so now that we're working on Python support for NetBeans we'll need to bundle the YAML support with Python as well.

Hi Ruby Freeman,
Sorry, I don't know anything about the HAML plugin; it was contributed by somebody else and I've never seen the sources (plus I think it's built on top of the Schliemann infrastructure, the same one that YAML used to be built on before I rewrote it as described in this blog entry).

Posted by Tor Norbye on July 14, 2008 at 09:43 AM PDT #

Update: Ola has released a new version of the YAML parser with some fixes, so I've now enabled code folding in the YAML editor as well.

Posted by Tor Norbye on July 15, 2008 at 09:53 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

Tor Norbye

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today