Scala Plugin 1.2 RC Introduces Ahead-of-time Code Completion
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!
Performance tips for IntelliJ Scala Plugin
A full-blown IDE is one of the most complicated applications you can find on an average laptop. This is why we – the Scala plugin team at JetBrains – from time to time receive reports that our product lags in certain situations or works slowly in general. In some of these cases we can help, but in o…
Dataflow Analysis for Scala
One of the things IntelliJ IDEA is most famous for is its huge variety of helpful inspections and warnings. They make the lives of programmers significantly easier, frequently showing them errors in logic or style that they wouldn’t have noticed otherwise. Those inspections come in various shapes…
BSP Support for Bazel
The Build Server Protocol (BSP), a protocol initially developed by the Scala Center and JetBrains, enables the easy integration of IDEs and build tools. To give users even more options in the BSP ecosystem, we decided to add support for Bazel. While there is already a Bazel plugin for Intel…
IntelliJ Scala Plugin 2021.2 EAP: Package Search Integration
Package Search is a service developed by JetBrains that supports searching for libraries from multiple repositories such as Maven Central, Google Maven, and others. Since its introduction at the end of 2019, the Package Search plugin has made searching for and managing dependencies for Maven and …