Scala plugin for IntelliJ IDEA 2017.1: Cleaner UI, SBT shell, REPL worksheet, Akka support and more

This update brings many new features and improvements in different areas:

1. User interface

First, we’ve streamlined the project wizard:

Project Wizard

  • IDEA / SBT project formats are now clearly separated.
  • SBT project is now the default format.
  • There’s a brand-new SBT icon!

Next, we’ve simplified the wizard settings (which is especially important for novice users):

Project Settings

The handling of Dotty is upgraded:

Dotty Selection

  • Dotty SDK is now just a subtype of Scala SDK.
  • It’s possible to create / import SBT Dotty projects.

Now you can paste Scala code directly into the Project View, for example you can copy the following text:

…and paste it into the project tree – and the new Scala file with a proper name and a package statement will be created automatically. “Stack Overflow driven development” has never been easier! :)

Paste Class

Last but not least, we’ve reworked all the refactoring / code generation dialogs to make them uniform and easier to use.

2. SBT support

We’ve added a built-in SBT shell, which can be started via the SBT tool window. Autocomplete makes it easier to run SBT commands:

SBT shell

You can also run SBT tasks directly from the SBT tool window:

SBT Tasks

It’s now possible to build projects using SBT (instead of IntelliJ IDEA’s internal build system). As this option is still experimental, it should be manually enabled via Build / Execution / Deployment / Build Tools / SBT / Use SBT shell for build and import:

SBT Preferences

Another experimental option is running tests via SBT:

SBT Tests

Select Use SBT in the Run Configuration to enable the option. Also select Use UI with SBT to present the results in the standard IDEA test runner:

Test Settings

3. Worksheet

Worksheet architecture now supports REPL mode, which evaluates only newly added expressions without recompiling the existing code:

REPL

The Worksheet + REPL combo brings the best of both words: although the evaluation is incremental, you don’t have to wait before typing the next line. Plus you can easily correct previous lines and re-evaluate them, if needed.

As the REPL mode can provide better performance, we plan to use this mode by default in the future. Moreover, we’re considering using the REPL mode for implementation of the standard Scala console.

4. Сode conversion

The Java-to-Scala code conversion is substantially improved. For example, it’s now possible to automatically convert something like this (warning, it contains Java):

Code (before)

…to this:

Code (after)

While previously the conversion worked only for Java code that was copied from IDEA, now it’s possible to convert Java code from text. Here’s an example for you to try:

Simply paste the snippet into a Scala file to see the result. The plugin relies on IntelliJ IDEA’s parser to detect valid Java code for the conversion.

5. Akka

The Ultimate version of the plugin also got a boost – we’ve improved support for Akka. First, we made Find Usages Akka-aware so now it can classify usages of a message class depending on the context:

Find Usages

You can use this to easily find senders or receivers of a particular message in your code.

Because Akka has many “dynamic” parts, some errors are not reported by the Scala compiler. IDE assistance can be of great help in detecting those errors statically (before they are “detected” at runtime).

For example, IntelliJ IDEA can make sure that arguments to a factory method match the actor constructor:

Props

Another thing that can be automated is the generation of factory methods:

Generate Factory Method

The automatically generated code:

Factory Method

Develop with Pleasure!

About Pavel Fatin

Programming enthusiast, technology advocate. IntelliJ Scala plugin developer at JetBrains, https://pavelfatin.com
This entry was posted in New Features, Release report, Uncategorized. Bookmark the permalink.

18 Responses to Scala plugin for IntelliJ IDEA 2017.1: Cleaner UI, SBT shell, REPL worksheet, Akka support and more

  1. James Moore says:

    One of the first things that’s a bit confusing for a new user is the project import dialog box telling me that I need to select the “modules / data to include in the project”. I have no idea what that means (so I just click the OK box, figuring the default is probably right).

    https://docs.google.com/document/d/1So4Id-qxn0LFiBNUuzNS-XFgVyxTAHF4K3AT2sEjFLo/pub

  2. Pavel Fatin says:

    Hi James,

    Thanks for the report! We completely agree with you – that dialog is confusing and, actually, unnecessary – the Help button might show something like “Press OK here” :) The problem is known, yet we are currently constrained by the architectural limitations. We’ll do our best to circumvent the restrictions and to simplify the project import experience further.

    • Shane says:

      The ticket you link to as “architectural limitations” is not publicly visible, even when I am logged into youtrack.

  3. Chris Beach says:

    Thanks so much, guys. IntelliJ’s Scala support makes coding an absolute pleasure and I love that improvements keep coming.

    If I could have one wish, it would be to see non-compiling Scala files highlighted in the project tree view. At the moment I click through from the “Problems” tab, but it would be really helpful to see more visually which part of the project tree is broken by a code change.

    Thanks again and keep up the good work!.

  4. Leszek says:

    This is fantastic, thanks for hard work!
    We’re closer to times when there will be no need for SBT running in a terminal next to IDEA :-)

    • Jacek says:

      Right, Leszek! Can’t wait to see that happened.

      p.s. I’d strongly suggest running sbt *inside* a terminal window in IDEA. That way you don’t have to leave your beloved development environment (and have it available under Alt+F12).

      p.s.2 Wish there could be a way to launch a new terminal window (to have two or more) using a key shortcut. Currently, have to click the little green plus :(

      • Alexander Podkhalyuzin says:

        You always can map any shortcut on action “Start SBT Shell” in Keymap settings page. But probably you are right that we need to define some default value.

  5. Sven says:

    Great update guys! I love especially the SBT Shell. Unfortunately there is one quirk in conjunction with play projects: The SBT Shell doesn’t react to [Ctrl]+[D] which is required to stop the running play app and return to the SBT console. Any chance to get this solved?

  6. Nikolay says:

    Very good news, thanks! )) Glad to see SBT shell inside IDE. Side shell is not so convenient as embedded.

  7. Daniil says:

    is there possible to setup codepage at SBT shell? at Windows 7 cyrillic character representation is broken.

  8. Allan says:

    This is a step in the right direction. Still it is not as easy to use as the original sbt console plugin used to be (when the arrow keys worked to go back to previous commands).

    The sbt prompt is displayed in a confusing way: It displays an X when busy and when you type Enter it displays a new prompt on the previous line.

    There are no buttons to go to the next or previous error or to control automatic scrolling at the end of the output.

    But it is nice to have this feature in Idea.

  9. Hagai says:

    Hi Pavel, since the installation on 17.1 I’m getting “No scala SDK defined on module. Setup a scala SDK…” on each new scala module in my project.
    I already defined it several times but it keeps showing up. It’s also defined in the Global Libraries of my project settins.

    ideas?

    • Hagai says:

      Just to mentioned that I upgraded from 16.3 where I didn’t have this issue. I’m using a licensed Ultimate version.

  10. Pingback: Scala дайджест #7: новая среда AI на основе Scala, популярность языков для DataScience, видео ScalaUA и ScalaDays : IT лента новостей ⋆ iAMX - Развлекательно-инфор

  11. Pingback: Scala дайджест #7: новая среда AI на основе Scala, популярность языков для DataScience, видео ScalaUA и ScalaDays - LIKELY.CLUB

Leave a Reply

Your email address will not be published. Required fields are marked *