Friday April 20, 2007 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.
(2007-04-20 16:06:13.0) Permalink Comments [11]
Posted by Greg Fodor on April 20, 2007 at 05:56 PM PDT #
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 07:56 PM PDT #
Posted by Tor Norbye on April 21, 2007 at 10:19 AM PDT #
Posted by Ralph on April 21, 2007 at 11:50 AM PDT #
Posted by GregH on April 21, 2007 at 12:32 PM PDT #
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 02:54 PM PDT #
Posted by GregH on April 21, 2007 at 03:54 PM PDT #
Posted by Fabian on April 22, 2007 at 05:12 AM PDT #
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 22, 2007 at 06:42 AM PDT #
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 09:24 AM PDT #
Posted by Tor Norbye's Weblog on April 25, 2007 at 12:39 PM PDT #