Archive for November 11th, 2008

More Types Intelligence in RubyMine

Tuesday, November 11th, 2008

In the previous article covering type inference we’ve reviewed the following cases:

  • Type Inference for local variables
  • Detecting for index variable type
  • Understanding true, false and nil

But there’s more, much more…
Let’s see more intelligence RubyMine shows when editing Ruby code.

Unknown Method Calls

If in your code you make a method call or reference an attribute that RubyMine for some reason cannot resolve, you will be notified about it by the appropriate inspection but only once for this particular method and current variable. And your code will not look all red.

If you press Ctrl+B/⌘ B on such method call it will resolve to the first occurrence where inspection error is shown.

Custom Error Types

RubyMine correctly resolves your custom exceptions and their methods when you want to handle errors in your code.


class MyError < RuntimeError # custom class representing an error
  def foo
    #foo body
  end
end

begin
  # do_something
  rescue MyError => err
    err.foo
end

Code completion shows the methods and attributes of custom error class MyError.

(more…)