Ruby Screenshot of the Week #10: Taking Up The Gauntlet

SapphireSteel, makers of the Ruby In Steel plugin for Microsoft Visual Studio, has been touting their own code completion feature for a while. One thing which has irked me a bit is that they tend to dismiss "code completion" as inferior to "true IntelliSense" - as if code completion is the name for simple identifier matching. Just to be clear - IntelliSense is a trademark of Microsoft, so nobody else calls the same feature that. Borland has referred to it as CodeInsight, but most IDEs refer to this feature as code completion.

In this article, SapphireSteel is throwing down the gauntlet by encouraging their users to see if anyone else can produce results like theirs:

To the best of our knowledge, Ruby In Steel’s IntelliSense for Ruby is unrivalled by any other IDE. {...} We’ve also supplied a few files from our IntelliSense test suite which we invite you to use with Ruby In Steel and any other editor or IDE of your choice.

So, I thought I would show what code completion in NetBeans is capable of. Let's start with test 1, which calls for code completion on an array literal in the source:

As you can see, we show the type of methods right in the code completion dialog. It doesn't matter much for an Array, but if you had invoked code completion on the numbers themselves, you'd see that some methods are coming from Integer, and some are coming from its parent class Numeric - and sometimes it's interesting to know that. Next, let's look at test 2:

The above example shows the type analyzer tracking types of variables. More interestingly, notice that while we show the methods on the class "above the line", there are other methods there too. Those are methods inherited into MyClass. In the SapphireSteel screenshots, these methods were turned off, presumably because in Visual Studio they would be interleaved with the regular methods. The evaluation document describes how you can turn Object inheritance on and off in the options. I think our solution is nicer because you get the best of both worlds: the methods you are likely most interested in appear first, but when you ned the "standard" methods (they are there for a reason, after all), they also appear. Thus, if you have a String object and you're completing on the letter "e", you see "empty?" (a String method), but also "eval" (an Object method).

Next, test 3 which tests module mixins:

Looks fine - and so does test 4 which is a more complicated scope test:

Anyway, I don't want to imply that our code completion is perfect! I still have a lot of things I want to do in our type inference engine. In particular, I want to make sure that code completion works well where it really matters: In code you're writing. Here's a final screenshot from a Rails application where you're writing a controller. Code completion works on important methods like render, or a method I found myself calling the other day - send_file:

Rails does a number of things that are very tricky to handle for the IDE, so I'll be spending more time in this area to improve code completion for Rails apps.

P.S. To try it yourself, get bits from nbextras.org. As of yesterday we're in Milestone 9 stabilization, so a promoted build should be available within the next couple of weeks.

Comments:

Hey Tor, Great work on all this stuff. I am currently evaluating Ruby IDEs and the work you guys have done is impressive. However, a showstopper for me is the absence of a Go to type tool. I often navigate through my project by bouncing from class to class, is this something you guys plan on doing soon or is it a "last mile" feature? Is there a workaround? I know there is a "go to file" plugin for netbeans but it unfortunately doesn't support wildcards. I am currently using the IntelliJ plugin which supports wildcarded go to type and go to symbol navigation, which makes navigating our codebase easy. I wish I had the code completion you guys have built though :) Thanks again, look forward to seeing your progress.

Posted by Greg Fodor on April 20, 2007 at 10:56 AM PDT #

Open Type is coming. Ok - some proof - here's a screenshot: http://blogs.sun.com/tor/resource/goto-type.png. Yes, it supports wildcards and camel caps support - and no, it's not a doctored picture.

The problem is that this hooks into the central IDE infrastructure, moving the Java-specific one into something other languages can plug into, so I need to clean up the API etc. It's after feature freeze for Milestone 9 so I can't make UI changes - but it will be there soon!

Posted by Tor Norbye on April 20, 2007 at 12:56 PM PDT #

Ok, see http://blogs.sun.com/tor/entry/saturday_morning_hack for a temporary solution.

Posted by Tor Norbye on April 21, 2007 at 03:19 AM PDT #

Hi Tor, was curious about responses on the previous screenshot... Seems like a few of us were left floating at the end.

Posted by Ralph on April 21, 2007 at 04:50 AM PDT #

Tor - when Milestone 9 comes out does that mean we should download this as a full new install, and then use update centre just for the ruby module updates? Also are the 'code template tools' module used for importing Textmate bundles going to be in the Ruby Feature from Update Centre in the next milestone release? Cheers Greg

Posted by GregH on April 21, 2007 at 05:32 AM PDT #

I'm not sure exactly what the Milestone 9 download story will be. The Update Center has been replaced by the Plugin Manager, which is making it a lot easier to update existing bits (without hunting through potential module candidates), etc. It's also going to make it easier to manage sets of related modules, so that I'll no longer need to maintain the "umbrella" module with dependencies etc. I think that part of the plugin manager is planned for Milestone 10.

However, there are also plans to make it easy to get the bits you want in the first place. There's a new installation process - there's a nightly build here: http://bits.nbextras.org/netbeans/6.0/nightly/latest/installers/. Unfortunately, while you can get Ruby preinstalled in one of those bundles, it comes with lots of other stuff. I'm investigating to see if we can get a Ruby only version, or perhaps Ruby+Java (but without web services, UML, etc.)

Posted by Tor Norbye on April 21, 2007 at 07:54 AM PDT #

Tor - Personally as I don't have too much time for Netbeans testing I'm quite happy to stay on the current version I have until you recommend us changing (i.e. ignoring daily builds, but when there is a milestone or new set of Ruby modules that we should upgrade to do this when you advise us on your blog) - Cheers Greg

Posted by GregH on April 21, 2007 at 08:54 AM PDT #

Hello Tor, thanks for the great work. Small question: What about the integration of attributes defined by attr_reader? Is this going to be implemented? I've also added this as a request in netbeans issuezilla but I'm not sure about the current status of the request. Cheers Fabian

Posted by Fabian on April 21, 2007 at 10:12 PM PDT #

Hi Greg, If you're happy with the bits you have then stick with those for now; Milestone 9 should be pretty stable so I'll let you know when that's available. (I did discover that while the installer link I pointed to above doesn't let you download ruby-only bits, that's only at download time; when you install you get to pick and choose which components to actually build the IDE from.)

Hi Fabian, att_reader support has been there for a while in terms of the navigator - but fields and attributes aren't included in code completion yet. I'll hopefully get to it soon!

Posted by Tor Norbye on April 21, 2007 at 11:42 PM PDT #

Noticed the support for method argument suggestion - is there any plan to add support for hash arguments? Some sort of comment annotation, perhaps? Most of my methods take one argument: either a hash:

def a_method args = {}
end
a_method :foo => 7, :bar => 'x', :something => 13

It's much less common to do Java-style

def a_method foo, bar, something
end
a_method 7, 'x', 13

Posted by James Moore on April 22, 2007 at 02:24 AM PDT #

James, yes - I'd like to do something in this area. It will be very tricky to do anything automated in this area; most likely it will take the form of some kind of documentation convention.

Posted by Tor Norbye's Weblog on April 25, 2007 at 05:39 AM PDT #

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

Tor Norbye

Search

Archives
« April 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
   
       
Today