Posts Tagged ‘code completion’

What’s mining: Ruby support within HAML

Friday, July 3rd, 2009

As you may know RubyMine provides outstanding Ruby code editing support in Erb files (RHTML). So, salute another language with Ruby code support: HAML. Familiar things like on the fly error highlighting, code completion, resolve, code folding, and much more are here to boost your productivity! And of course RubyMine is aware of HAML semantics and ruby blocks are recognized correctly according to indentations.

Here, in support of the words, we have some screenshots:

Ruby code completion:
    Ruby code folding:

This stuff will be available in RubyMine 1.5 EAP coming soon! Stay in touch!

-JetBrains RubyMine Team

RubyMine Rails-specific Code Completion

Wednesday, November 26th, 2008

And finally, the Rails! Rails is probably why most of us is using Ruby, right? So, RubyMine helps coding when Ruby on Rails is used.

Ruby on Rails Smartness #1

When a variable holds a model object RubyMine knows its type, its details and wisely offers the code completion.

And once you select first attribute to find_by you can try once again and RubyMine suggests again to create a complex find statement.

Ruby on Rails Smartness #2

Many Rails methods expect parameters of a certain kind or format. One example of such methods is validation methods (validate_uniqueness_of, validates_numericality_of, etc.).

RubyMine knows what should be in completion list after such methods, finds and suggests appropriate names.

Ruby on Rails Smartness #3

Quite often methods take hashes as parameters with only certain key values, ignoring the others.


class AdminController < ApplicationController

  def logout
    session[:user_id] = nil
    flash[:notice] = "Logged out"
    render :action => :index, :partial => 'bye'
  end

  def index

  end

end

Some parameters of render hash in a controller are :partial, :action, :layout and :template.

When these are used the right part of the hash is clear.

For :partial it is partial view,

For :action — the action from the controller or its parent.

For other supported parameters check the documentation.

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…)