Scala Plugin 1.2 RC Introduces Ahead-of-time Code Completion

Posted on by Pavel Fatin

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:

  1. automatically complete a type reference,
  2. 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):

scala_aot_completion_1

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:

scala_aot_completion_2

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!

Comments below can no longer be edited.

8 Responses to Scala Plugin 1.2 RC Introduces Ahead-of-time Code Completion

  1. Kieron Robinson says:

    December 9, 2014

    Great works guys! Can’t wait to try it out…

  2. Peter Gromov says:

    December 10, 2014

    Cool!

  3. OlegYch says:

    December 10, 2014

    Awesome! works very nicely

  4. Tatarinov Nikolay says:

    December 10, 2014

    First of all, thank you for the work, and the fact that scala developers can enjoy scala coding in Intellij Idea (which is great tool).
    I just wanted to tell about user experience. Recently I hear many complaints about Idea 14 and updated scala plugin. Mostly they are about highlighting errors and integration issues with some popular scala frameworks(like play, shapeless and scalaz). Here is a link to russian-speaiking skype chat intended for scala developers http://bit.ly/scalachat . I think you could collect some valuable feedback directly from users here. It could be valuable and helpful for plugin improvement process.

  5. Randall Schulz says:

    December 13, 2014

    Where is it? There is no 1.2.* on http://confluence.jetbrains.com/display/SCA/Scala+plugin+EAP nor does a 1.2 release show up in http://www.jetbrains.com/idea/plugins/scala-eap-cassiopeia.xml

    Has the 1.2 plug-in been withdrawn?

    • Andrey Cheptsov says:

      December 17, 2014

      Yes, it’s a bit confusing. Actually 1.1.382.2.RC1 is 1.2 RC1, and “1.1.382.2” here is a build number. Will update the page to eliminate misunderstanding.

  6. Scala Plugin 1.2 for IntelliJ IDEA 14 发布 | 我爱互联网 says:

    December 17, 2014

    […] 更多这方面的内容请看corresponding EAP announcement。 […]

  7. Matt says:

    May 23, 2015

    Congratulations! the Scala plugin is coming along in leap and bounds. The only issue I still have with it is incorrect syntax errors in parboiled2 grammars, no doubt there are still some bugs in the macro expanding.