IntelliJ Scala Plugin 2019.3: Method Chain Hints, Scala REPL, Scala Worksheet, and ScalaTest improvements

Just like IntelliJ IDEA 2019.3, this release of the Scala Plugin is focused primarily on performance boosts and usability enhancements. And yet, we managed to sneak in a cool new feature as well. Let’s take a closer look.

1. Method chain hints
2. Inlay hint settings
3. Searchable settings
4. Scala REPL improvements
5. Scala Worksheet improvements
6. ScalaTest gutter icons
7. Up-to-date Java-to-Scala converter

Method chain hints

To tell the truth, the “new” feature is not entirely new because starting with version 2018.2, IntelliJ IDEA has been able to show type hints for long method chains:

java-method-chain-hints

This functionality, however, has been limited to Java. What’s more, the Java’s approach is hardly applicable in Scala, where long method chains are much more common and we often pass function literals in curly braces, etc. To prevent method chain hints from interfering with Scala code, we can display the hints in a separate column:

scala-method-chain-hints-2

This mode is indeed new, and only the Scala plugin can show the aligned hints so far. In functional programming, there’s the idea that “names are not important, only types are.” Withdrawing judgment, you can definitely learn a lot simply by looking at the type flow. In some sense, this feature reveals the “type level” of your code. (Interestingly, you cannot easily replicate that in the code as such. While you can add type annotations explicitly, there’s no easy way to add type ascription to each line in a long chain of method calls.)

We also offer the classic presentation. Even that mode is less noisy than Java’s counterpart, because the Scala plugin can omit hints when the type is obvious. By the way, you may always tweak the minimum number of unique types in a chain that are required to show the hints.

Inlay hint settings

The Scala plugin now takes advantage of IntelliJ IDEA’s dedicated settings for inlay hints (in Settings | Editor | Inlay hints):

hint-settings

We’ve rearranged and simplified the settings, and added examples that demonstrate the hints right away. The basic options are also available in the context menu:

context-menu

You can open the extended settings by using the Configure… command.

Searchable settings

As you probably know, you can simply type a query to start searching IntelliJ IDEA’s Settings. So far so good, but this capability requires a special assistance from setting providers, and most Scala-related settings have not been searchable… until now:

settings-search

OK, hardly revolutionary, but it’s a nice thing to have.

Scala REPL improvements

Amazing but true: the Scala plugin has a built-in Scala REPL that doesn’t require tinkering with terminals, classpath, and installing Scala binaries in your operating system. You can start the REPL by invoking Tools | Scala REPL (or by pressing Ctrl + Shift + D):

scala-repl

This feature is not widely known, not least because of the previously subpar UX. In this release, we’ve made this feature a lot more usable:

  • It is now called “Scala REPL”, not “Scala Console”.
  • You can use Enter instead of Ctrl (Cmd) + Enter.
  • The input is placed right after the scala> prompt, not a few lines below.

So, the build-in Scala REPL now works very much like the standard Scala REPL. If you did not use the built-in version before, you are welcome to try this one.

Scala Worksheet improvement

Scala Worksheet is another feature that is revamped in this release as we’ve added more reliable error handling. Previously, there could be an error, but no visual feedback. Now, Scala Worksheet can handle multiple types of possible errors, which can now be easily detected and acted upon.

scala-worksheet

ScalaTest gutter icons

You can now run individual ScalaTests:

scala-test-gutter-icons

Up-to-date Java-to-Scala converter

The Java to Scala converter is now up-to-date with Java: it can handle counting loops and switch expressions, and can remove redundant break statements automatically:

java-to-scala-converter-2

And much more!

There are many more improvements, but they are both too numerous and too technical to include in the blog post. For instance, the Scala plugin now supports the so-called “Universal AST”, so that you can benefit from universal Android and Spring inspections in the platform. The support of Scala 2.13 has also been improved.

What really matters is that all this is included in the release. We use the Scala plugin ourselves to develop the Scala plugin, and we feel that spending some time on polishing was definitely worth it – the plugin is now more reliable and pleasant to work with, which is definitely important if you like to develop with pleasure :)

Your feedback is very welcome, as always.

Sincerely,

The IntelliJ Scala Plugin Team

About Pavel Fatin

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

One Response to IntelliJ Scala Plugin 2019.3: Method Chain Hints, Scala REPL, Scala Worksheet, and ScalaTest improvements

  1. Jared Dobson says:

    This is really cool. Thanks a bunch for making it!!

Leave a Reply

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