Friday, August 17, 2012

GSoC: Improving KDevelop Ruby Support Part 2

Hi all!

In my last post I talked about some of the features I've been working on this GSoC period. Well, now it's time for code completion. Here it goes:
The first thing that KDevelop is showing us is the completion of some ruby builtins like require and require_relative. But I personally find more interesting the following:
It offers code completion for required files when possible. This is also true for the require_relative, as shown here:
Note that in the completion of required files, the final ".rb" is omitted in the end result. This is certainly cool, but let us continue with the code. Now I want to write an "if" statement. After writing "if", KDevelop offers me the completion for this keyword. If I hit enter, this is what happens:
KDevelop puts the "end" keyword for me and it's also reminding me that I should write a condition expression by selecting the "condition" word. Ok, now I want to use the SecureRandom module (which is reachable thanks to the first require) :
As you can see, KDevelop knows which class/modules/methods are reachable in the current context. In this case, the only module that KDevelop knows that starts with "Secure" is "SecureRandom". And finally, let's show code completion for method calls:
KDevelop detected that the class "User" has a method named "create!" and it's giving me some info about this method (parameters, returning type, ...).

And that is all for today.

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.

Thursday, August 9, 2012

Hello Planet

Hi there!

This is my first post on Planet KDE - so I'll start with a brief introduction of myself:

I'm Miquel Sabaté Solà (mssola on IRC) and I'm a 22-year old, computer science student at the Barcelona School of Informatics, Spain. Since a year or so, I've been working on the Ruby language support for KDevelop and this summer I've been selected in GSoC 2012 to improve this same language support. The goals of this GSoC are:

  • Make the Ruby plugin as stable as possible.
  • Uses of variables, module mixins, etc. are reported.
  • Offer some basic code completion.
  • Navigation using the context browser tools work.
  • The QuickOpen interface shows some Ruby features such as telling the user where a specific class has been re-opened, etc.
In the following days I'll write a serie of blog posts getting into the details of the work I've done in this GSoC, and showing some fancy snapshots ;)

So... stay tuned !