With the just published Scala Plugin 1.2 RC build, we’re happy to pioneer a new kind of coding assistance, which we like to call “ahead of time” (AOT) code completion.
Have you ever noticed that unlike Java, in Scala we have to spend more time actually typing all the parameter and variable names? In Java we can always do this:
- automatically complete a type reference,
- then automatically complete a corresponding parameter or variable name.
Which is very quick and really convenient. Unfortunately, this won’t do in Scala directly because of these reasons:
- order of variable type and name is reversed and,
- type annotation is optional and therefore may never exist.
So everyone programming Scala was completely denied all of this completion coolness… until now. We’ve changed the rules: now it’s possible to automatically complete both the name and the type before actually adding a type reference (and that is why we call it “ahead of time” completion):
Basically, for class and method parameters you can imagine that autocomplete is invoked one step further, on the type reference, with a search string capitalized, so that:
- you can start autocomplete either via “auto-popup”, or manually, by pressing Ctrl + Space,
- you may press Ctrl + Space one more time, to broaden the scope of search,
- it’s possible to start a search from the middle of type name (“element” for “element: PsiElement”),
- it’s possible to use CamelHumps (“mEve” for “mouseEvent: MouseEvent”),
- the type reference is automatically imported, if needed.
As for values and variables, we’ve modified the described algorithm so that no type annotation is inserted (only the name part is completed), and the search scope is reduced to explicitly imported classes:
This algorithm is still work in progress, so the current restrictions may be loosened after we get more intel from people who are actually using it.
The current implementation is available in Scala Plugin 1.2 RC. You may toggle the AOT completion via Settings / Scala / Core page.
So, now we can develop with even more pleasure, and we hope that other languages (yo Kotlin!) and IDEs will follow. Your suggestions are welcome!