the blog
Back to -Blog

Evaluating Ruby IntelliSense

Put Your IDE To The Test...
by Huw Collingbourne
Friday 13 April 2007.

In the time that we’ve been developing Ruby In Steel, we’ve come to realise that there is a widespread misunderstanding about what IntelliSense actually is. Many IDEs offer some kind of simple code-completion, whereby methods can be selected from a drop-down list. Very few IDEs indeed, offer anything approximating to IntelliSense.

An IntelliSense system must be capable of displaying appropriate completion lists (that is, only those methods which are available to objects of a specific type) for both variables and literals. Here, for example, we have a completion lists showing array methods for an array literal. Notice we also have automatic tooltip help for each selected method.

To the best of our knowledge, Ruby In Steel’s IntelliSense for Ruby is unrivalled by any other IDE. If anyone can find another IDE that does as good a job or better, please let us know and we’ll do everything in our power to make our Intellisense better still.

At the very least, any IDE that offers even the most basic type of code completion should be able to provide lists of methods (and only those methods) relating to your own custom classes.

In order to help you understand IntelliSense and to test out the capabilities of Ruby In Steel and other IDEs, I’ve written this short guide. 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. We actually have many hundreds of files in our internal IntelliSense test suite which we use to test even the most bizarre combinations of code constructs. The sample download we’ve provide here, however, contains just 6 files to illustrate a few of the more obvious problems which any real IntelliSense system has to solve. Download the test files at the bottom of this article. Instructions are provided in comments in the code.

Things get more complicated when you start dealing with ’mixed in’ modules. Here, the ob object is created from class C inside the M3 module. Bu this class includes (mixes in) two other modules, M1 and M2, each of which contains another method, m1_method and m2_method. Notice that the completion list of the ob object correctly shows the mixed in methods.

Ruby IntelliSense is integrated into Ruby In Steel Developer, including the 30-Day Trial Edition. It is not included in the free Personal Edition.

What Is IntelliSense Anyway?

The IntelliSense engine analyses code as it is entered in order to ’work out’ which methods belong to any given variable, taking into account methods that have been inherited from ancestor classes, the visibility of methods due to scoping rules or other factors (e.g. does a method belong to a class or an object? Is it a singleton - a special one-off variation of a class? - or has a method been ’mixed in’ to the current class using a Ruby ’include’?)

Note that Ruby In Steel provides IntelliSense in response not only to a dot after a variable name [ . ] but also to a double-colon [ :: ], which is used with classes and modules.

NOTE: Before working with IntelliSense in Ruby In Steel, you may want to disable the display of Object methods. By default, Ruby In Steel displays all methods throughout a class’s ancestry up to and including the base class, Object. While this may be useful when coding, the sheer number of methods provided by Object make it difficult to see how the IntelliSense works. To disable the display of Object methods, select: Tools, Options, Text Editor, Ruby, IntelliSense and ensure that the ’Display Object methods’ option is not checked. The exception is when using the test file, object_methods.rb, which requires that Object methods be shown.

Ruby’s scoping rules all complications for IntelliSense. Here we fire a completion list with two colons, ::, after the X class. This correctly shows that we have access to the Y class and to the x1 method (plus some other standard Ruby methods for a class), but it does not show the ’nested’ class, Z, or the instance methods, x2, p and q.

In some circumstances, inferring the type of an object is, even in principle, impossible. Far example, a method can take untyped parameters and its return type may be unspecified or ambiguous. In such cases you can create extra IntelliSense by asserting the expected types in a comment block. These types will then be displayed in ’parameter hints’. The type_assertions.rb file shows a simple example of this. Refer to the Ruby In Steel manual for a more detailed explanation.


IntelliSense features provided by Ruby In Steel include:

- Member completion lists
- Keyword completion lists
- Parameter completion lists
- Globals completion
- Variables completion
- Intelligent Type Inference
- Optional type assertion of method return
- Optional type assertion of arguments
- Auto-expand snippets
- Auto-surround snippets
- Dedicated Ruby Snippet Editor
- RDoc display in tooltips
- Tooltip Help over Completion Lists
- Navigation bars (drop-down Lists) In Editor

Our IntelliSense also include parameter info in tooltips to show the names and types of arguments. Using our optional ’type assertions’ you can even add more type information than is available in the Ruby code itself.

For more information, see:
- IntelliSense Overview
- IntelliSense screencasts
- IntelliSense and Parsing Ruby
- IntelliSense (phase 1)
- IntelliSense in depth
- Ruby IntelliSense – the finer points
- Ruby IntelliSense – scoping fun
- Filling out IntelliSense
- Ruby Variable Completion - The Challenges Of Code Analysis

Bookmark and Share   Keywords:  ide

Use these code files to test a few simple IntelliSense fetures.

3.6 kb
© SapphireSteel Software 2014