Google Summer of Code 2014: QML/Javascript language support for KDevelop 4 and 5
Hi,
Today is the end of the Google Summer of Code 2014 coding period. This year, I added support for the QML and Javascript languages in KDevelop. Both languages were added at the same time because QML is a superset of Javascript (one can embed JS snippets in QML files).
This has been a very exciting project. I started working on it on March 9, 2014, a bit before the community bonding period started, and I added features for nearly six months since then. The QML/JS language support for KDevelop (which lives in kde:kdev-qmljs
, branch kde4 for KDE4 code, branch frameworks for KF5) is now complete and functional. Sure, there are always features that can be added (and I give some examples at the end of this blog post), but Javascript and QML files are now reliably parsed, and several developers already use the plugin. A released version may come shortly.
Features
Here is a list of screenshots, each with a short description, listing the most important features of the QML/JS plugin. This list is intented to be a summary of what have been developed during the GSoC period, so that the users know what they can expect from the plugin. This is a list of features available in both the KDE4 and the KF5 version of the plugin. The screenshots come from already-published blog posts, so please forgive me if something does not look exactly as it is now :-) .
Type inference of function parameters when a function is called. This is needed because a function usually does not assign a value to its parameters, so normal type inference cannot be used.
Function call-tips, with the name of the parameters and best matches:
Field members and array members:
Understanding of complex Javascript features like prototype-oriented programming:
Javascript "classes" and import of Javascript files in QML (this screenshot actually shows many features :-) ):
And it also has support for Node.js modules (thanks to Àlex Fiestas who repeatedly asked me for this feature):
Support for ECMAScript and DOM types (QML/JS understands as many DOM types as Webkit, from which I've taken the .idl description files):
KDevelop can now display a list of QML properties:
When you write a signal handler, the parameters of the signal handler are part of the current context:
Some helper widgets allow you to quickly enter a QML property value:
KDevelop 5 features
KDevelop 5 being based on Qt5 and KF5, more features become possible. For instance, the QtQuick.Controls
module allows the QML/JS plugin to display a nice font chooser (that is a read-only font preview in KDE4):
A new "problems" infrastructure has been added. QML/JS now displays problems when it is absolutely sure that there is something wrong (a mismatch between QML types when both types are sure, for instance, or a missing imported module, so that the user knows why some symbols are not resolved properly):
Code-completion for Node.js require statements:
Future plans
The official coding period is now finished. It has been a wonderful experience and I had the occasion to meet many interesting people. I would like to give many thanks to Sven Brauch, my mentor, who has helped me understand the KDevelop code-base. His Python plugin has also been a great inspiration for me. I'm unable to remember how many times I thought "I don't know what to do, let's see what Python does".
Other people also greatly helped me. For instance, Aleix Pol gave me advice at the very beginning of the coding period and at the very end (just now, in Randa!), Milian Wolff carefully reviewed most of my commits and review requests and was of great help when I had problems with the most internal parts of KDevelop, and Kevin Funk (who worked on kdev-clang for his GSoC) fixed many annoying bugs in KDevPlatform. I also thank every early user of kdev-qmljs who posted nice comments on my blog, encouraged me, and asked for features. Special thanks for Àlex Fiestas without whom half the features of QML/JS would not exist.
Regarding the future, I'll start by being honest and say that I need some sleep. I've worked more than full-time for six months, in addition to the university, because I can't stop working when I'm excited by what I'm doing. Now I need some days of rest, and I will also work a bit on the Baloo query parser that needs some love in order to be fully usable. It is already ported to KF5 and interesting things are coming, more on that (with screenshots) in a couple of days :-) . After that, I'll continue working on what I like: Baloo, KDevelop (QML/JS and other things), and api.kde.org.