Tuesday, August 14, 2012

GSoC: Improving KDevelop Ruby Support Part 1

Hi there!

As I promised in my previous blog post, it's time to show some of the work I've done in this GSoC. Most of my efforts have focused on re-building the internals from scratch, and some of the goals of doing so was to provide some cool type guessing and some useful code navigation. Let me show you this features with a simple example:
As always, KDevelop stores some information about class definitions and, in this case, it also keeps track of the modules that have been mixed in this class definition. Alternatively, if we hover the mouse over the "Enumerable", this is what happens:
This is the documentation of the Enumerable module. KDevelop is also listing us the classes/modules where the Enumerable module has been mixed in. Now, let's hover the mouse over a method definition:
The type of the parameter "something" has been guessed from the method call in the line 28. However, the type of some method parameters can be guessed even if no one is using this method:
The parameter "block" is a Proc, as expected. More on types:
And finally let's take a look at two particular cases:
As you can see, the type of the "a" block variable has been guessed from the yield call of the method "another". The same goes for the "b" block variable. The second case is more interesting though:
As you can see, the variable "c" gets the value from the "item" method. First of all, KDevelop undersands ruby's implicit return, so the returning value from the "item" method is just "@list[0]". The "@list" instance variable is an array that has an item that is of type "Fixnum", and another one that is of type "String". KDevelop understands that "@list" is an array, but it can't know for sure what is the type of the item that is being accessed. That's what we see in this widget, c may be a String or a Fixnum.

And that's all for today! In the next post I'll show you more features introduced in this GSoC.


  1. Awesome! Can't wait for this to get shipped finally.

  2. Woooh, shiny! Good work Miquel!