Code Completion by IDEs - How Complete?

Hi

Continuing from “Moving to 3rd Rail”

After being educated on the virtues of NBRubyIde, I was motivated to
actually checked out code completion of the much maligned free Aptana
radrails. This is the result

  1. Type validates+ctrl-space
    1.1 NBRubyIDE
    Result :
    validates_presence_of *attr_names

1.2 Aptana RadRails
Result :
validates_presence_of(attributes, :message => “message”)

1.3 3rdRail
Result : My test license has expired

Cody, pse fill up the blank :slight_smile:

So guys, which IDE does better code completion ?

We are not aware of any IDE that equals the code completion in Ruby In
Steel. (both in terms of speed and accuracy) and we do test the others
pretty regularly. We have written a great deal about the technology that
lies behind this and we shall soon be releasing an updated evaluator’s
guide so that you can test our code completion against any other IDE.

More info here…
http://www.sapphiresteel.com/Ruby-On-Rails-Code-Completion-The
http://www.sapphiresteel.com/Ruby-On-Rails-IntelliSense-1
http://www.sapphiresteel.com/Evaluating-Ruby-IntelliSense

best wishes
Huw C.

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

Hi Huw

I wish I could test out your statement on code accuracy but
unfortunately, I don’t use VS :slight_smile:

Why don’t you post what RIS will output when one types

validates+ctrl+space ?

On Sep 26, 9:52 pm, Huw C. <rails-mailing-l…@andreas-

CCH wrote:

Cody, pse fill up the blank :slight_smile:

So guys, which IDE does better code completion ?

I’ll go through the various editors and post actual example of code
completion. I use code completion in the project commander when
executing scripts, in the style-sheet editor to remember a specific
selector, in the rhtml templates, and of course in the editor.

There’ll be a follow-up posting soon containing the examples…

Hi Cody

Great ! I am looking forward to your post :slight_smile:

On Sep 26, 10:33 pm, Cody S. [email protected]

CCH wrote:

Why don’t you post what RIS will output when one types

validates+ctrl+space ?

That all depends on the context and scope. We don’t use lookup lists. We
actually analyze all the code, its inheretence tree, mixins, scope
(class/instance), visibility (public/private) etc. That means that when
you are in a class that descends from ActiveRecord::Base you will see a
whole load of validation methods (too many for me to type in here) - but
when you are in some other scope (where they are not valid) you won’t
see any. The same goes for all classes, modules, methods etc. We never
ever use lookup lists - absolutely not ever. We always analyze code in
context.

I should say that this applies to the new version of Ruby In Steel 1.1.5
(currently available as a final beta). Earlier versions did full
analysis of Ruby but only partial analysis of Rails (for quite complex
reasons, Rails introduces some special problems for code completion). In
1.1.5 we’ve introduced full code analysis into Rails.

best wishes
Huw

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

Hi Huw

The context is that if one selects validates_presence_of , what does
RIS output ?

On Sep 26, 10:53 pm, Huw C. <rails-mailing-l…@andreas-

CCH wrote:

Hi Huw

The context is that if one selects validates_presence_of , what does
RIS output ?

I’m not quite sure what you mean by its “output”. If you enter part of
the name - e.g. val then press ctrl+space, you will get a list of
methods (in scope) that begin with those letters. The RDOC for
validates_presence_of is shown alongside it in a tooltip next to the
code completion list or (more nicely formatted) in a docked RDOC window
(this is the complete RDOC documentation which, for reference, I’ve put
at the end of this post).

The parameter list and class (here: attr_names:Object) can also be
displayed in a hovering tooltip. Here the parameter type is Object
because that is all that can be inferred from this method definition at
edit time. In many cases, we can infer specific class types such as
Array or String but it turns out that the code in the
validates_preesence_of method does not provide that information. We also
have a type assertion facility, however, whereby you can enter a comment
over a method - e.g.

#:return: => Array
#:arg: anArg => MyClass

This will then provide more detailed parameter info in tooltips than can
be inferred from the code itself.

best wishes
Huw

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

p.s. As promised, above, here’s our context-sensitive RDOC documentation
for validates_presence_of…

Validates that the specified attributes are not blank (as defined by
Object#blank?). Happens by default on save. Example:

class Person < ActiveRecord::Base
validates_presence_of :first_name
end

The first_name attribute must be in the object and it cannot be blank.

If you want to validate the presence of a boolean field (where the real
values are true and false),
you will want to use validates_inclusion_of :field_name, :in => [true,
false]
This is due to the way Object#blank? handles boolean values.
false.blank? # => true

Configuration options:

  • message - A custom error message (default is: “can’t be blank”)
  • on - Specifies when this validation is active (default is :save, other
    options :create, :update)
  • if - Specifies a method, proc or string to call to determine if the
    validation should
    occur (e.g. :if => :allow_validation, or :if => Proc.new { |user|
    user.signup_step > 2 }). The
    method, proc or string should return or evaluate to a true or false
    value.

Warning
Validate the presence of the foreign key, not the instance variable
itself.
Do this:
validate_presence_of :invoice_id

Not this:
validate_presence_of :invoice

If you validate the presence of the associated object, you will get
failures on saves when both the parent object and the child object are
new.
return: => Object
arg: attr_names => Object

Hi Huw

It would appear that all 3 IDEs displays a box for one to select the
validation method of choice.
However, it looks as if the resultant source codes are pasted
differently !

For example,

  1. using nbRubyIde, once selected, this will appear in your source
    codes

    validates_presence_of *attr_names

  2. using Aptana RadRails , the following is pasted

    validates_presence_of(attributes, :message => “message”)

Can you see the difference ?

What I am interested to know is the resultant code that will be pasted
automatically by RIS :slight_smile:

On Sep 27, 1:04 am, Huw C. <rails-mailing-l…@andreas-

What I am interested to know is the resultant code that will be pasted
automatically by RIS :slight_smile:

we insert:

validates_presence_of

We don’t insert any args by default. However, we display parametr-info
tooltips showing the args with each arg (when more than 1) highlighted
as it is entered by the user.

I should probably point out that we also have auto-expand snippets (and
a snippet editor) - these optionally have fill-in-the-gap insertion
points so you could create a snippet which, when you enter vp (say)
followed by a tab automatically expands to

validates_presence_of attr_names

Where attr_names would be highlighted ready to be edited. You can, of
course, create much more complex snippets to so that when you edit an id
(say a variable or parameter name) in one part of the snippet, the same
id is automatically changed throughout the remainder of the snippet.

In short then: code-completion (IntelliSense) is based on deep
code-analysis and only enters valid code (with no ‘place holders’);
snippets are auto-expanding code blocks which may contain a number of
place-holders that can be tabbed to and from and edited to change
similarly named placed-holders throughout the rest of the snippet.

best wishes
Huw

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

CCH wrote:

1.3 3rdRail
Result : My test license has expired

Cody, pse fill up the blank :slight_smile:

So guys, which IDE does better code completion ?

Ummm, you must not have registered your trial copy.

You need to register it to use it for the 30 day trial. Your trial
obviously isn’t expired since it was just released last week…

Hi Folks

In terms of code completion 3rdRail uses type inference to determine
what is appropriate for completion options. In some cases we’re better
then others, in some cases we’re trailing a bit. NetBeans uses
hueristics, in my experience this is limited and can offer a lot of
incorrect choices.

For example, in netbeans completion on
require “^” # cursor at ^ character
should give a reasonable list of choices. We didn’t think this was a
key use case.

In a form_for block in rhtml though we offer all of the right choices,
including the symbols for the models created in the action, ids, etc.
NB offers \t and \r, which didn’t help me.

I did a side-by-side comparison of 3rdRail and NetBeans last week and in
my view our completion is much more useful than NB. I know I’m biased,
but that was what I saw. I’m sure you could find cases on both sides,
it’s software after all. Absolutes are rare.

There is a short video that shows a bit of code completion here:
http://dn.codegear.com/article/37034

Trial downloads here
http://cc.codegear.com/free/3rdrail

Joe
3rdRail Team

Hi Joe

Nope, I was referring to the field test copy and not the trial copy.

On Sep 27, 7:55 am, Joe M. [email protected]

CCH wrote:

Hi Joe

Nope, I was referring to the field test copy and not the trial copy.

On Sep 27, 7:55 am, Joe M. [email protected]

Ahhh, the field test is over…that makes more sense. You can still get
the trial of course…

Hi Joe

Hi Joe

Asking the same question, what does 3rdrail insert when
validates_presence_of is selected ?

Hi Tor

Anyway, NetBeans doesn’t do parameter completion right yet; I had
started that work but disabled it until I could finish it as I got
distracted with other tasks. This discussion has inspired me to go and
look at that code again :slight_smile:

cch: I started this discussion :slight_smile:

It is great to know that you are so responsive.

For the time being, it looks as if RadRails have the best code
completion (for novices and newbies anyway)

BTW, I have been trying nbRubyIDE(standalone) on and off and one
concern of mine is starting speed and indexing of project.
I have perhaps 10 projects (each with perhaps 50 controllers or more)
in the nRubyIDE. It does take quite a bit of time to start up.
Is there anything that I can do on my end.

On Sep 26, 5:18 pm, Joe M. [email protected]
wrote:

Hi Folks

In terms of code completion 3rdRail uses type inference to determine
what is appropriate for completion options. {…} NetBeans uses
hueristics, in my experience this is limited and can offer a lot of
incorrect choices.

Just to be clear: NetBeans also uses type inference for completion
options such that in many cases it gives accurate results. The
validates-example listed earlier on this thread is one such example
where it knows exactly what the inherited and mixed in methods are in
the current context, and can complete accurately.

However, it -also- relies on heuristics in cases where it’s not sure,
such as a call to a method whose return type is unknown. I looked at
the video you linked to and the narrator states that 3rdRail relies
type inference and “Rails Conventions” - which sounds like heuristics
to me. And in a dynamic language like Ruby I don’t think there’s any
way to NOT use heuristics if you want to offer reasonable completion -
with methods and classes being modified dynamically computing the
correct set of methods etc. requires solving the Halting Problem.

Anyway, NetBeans doesn’t do parameter completion right yet; I had
started that work but disabled it until I could finish it as I got
distracted with other tasks. This discussion has inspired me to go and
look at that code again :slight_smile:

– Tor

From Tor
Just to be clear: NetBeans also uses type inference for completion
options such that in many cases it gives accurate results. The
validates-example listed earlier on this thread is one such example
where it knows exactly what the inherited and mixed in methods are in
the current context, and can complete accurately.

Hi Tor,

Thanks for the clarification, I have to admit my knowledge of the
inner workings of NB is second hand.

Joe

Hi Joe

Since there was no answer forthcoming from you as to what was inserted
on code completing validate, I decided to download the Trial.

Just wasted 1 hour to download the Trial just to get this message
3rd Rail Trial License , O (days) left on trail

What is this ? Wasn’t 3rdRail just launched on 17th Sept ???

Hi Anthony

Thanx !