Releases Scala Scala programming

IntelliJ Scala Plugin 2020.2 is released!

In addition to incremental improvements, this release brings a large number of essential new features to help with day to day Scala programming:

1. Auto-import for implicits
2. Indentation-based brace handling
3. First-class companions
4. Auto-import for object members
5. In-editor Scaladoc rendering
6. Completion improvements

Auto-import for implicits

While you can use View | Show Implicit Hints to display implicits (even absent ones), importing an implicit was never an easy task. The new Auto-import for implicits action works exactly like Auto-import for unresolved references, so you can now import implicits quickly and easily:

The automatic popup makes the feature more discoverable, but it’s also possible to disable the auto-popup (and invoke the Import… quick-fix with Alt + Enter):

For more details, see the corresponding blog post.

Indentation-based brace handling

Because Scala is a curly-bracket language, adding and removing curly braces is an integral part of Scala programmers’ everyday life. Those actions compound, so every improvement in this area matters. To make the task easier, we first added an intention to wrap and unwrap expressions, but it had to be invoked manually. Then we supported adding and removing complementary braces automatically, but you still had to add or remove a single brace… that is… until now.

Now we have taken it even further – both braces can be added and removed automatically and on the fly based on code indents:

With this, you can make use of significant indentation while still keeping the braces, even in Scala 2.x. To take advantage of this feature, just don’t think about the braces and let the IDE do the work. And it’s not just a catchphrase – to use the new feature, you must not use the legacy ones: don’t add a pair of {}, don’t invoke the "wrap" quick fix, and don’t insert an opening { manually.

The plugin can correctly handle appending or inserting a new line, keywords, and so on (and if braces are not needed, you can either press Enter twice or press Backspace to delete the indent). At the moment, the plugin doesn’t remove braces by default, but you can enable it in Editor | General | Smart Keys | Scala:

For more information, see the dedicated blog post.

First-class companions

In Scala, a companion class or trait and the companion object have a special relationship. We have long reflected this in Project View, but otherwise we have treated companions like any other classes or objects. Now we show navigable gutter icons for companions:

You can also navigate to a companion by using Go To on a class, trait, or object keyword. Companion object members can now easily be auto-completed or auto-imported:

The gutter icons are configurable in Settings | General | Editor | Gutter Icons:

Auto-import for object members

If you’ve ever used Java, you may have noticed that IntelliJ IDEA can auto-import static methods, such as emptyList, singletonList, etc. Although there are no static methods in Scala, there are object members, which we can now import automatically (as well as static members from Java):

You can use Esc to hide the auto-import popup and then press Alt+Enter to Import with prefix. Besides, you can press Ctrl+Space twice (or press Ctrl+Alt+Space) to autocomplete the identifier, as usual.

In-editor Scaladoc rendering

Scaladoc markup is easy to edit, but it’s not so easy to view – you have to wade through * columns, tags, and macros. Now we can render Scaladoc right in the editor, so it looks crisp and concise:

To Toggle Rendered View for a particular Scaladoc, click the gutter icon (or press Ctrl+Alt+Q). You can toggle rendering globally in Editor | General | Appearance:

We’ve also improved Scaladoc rendering in the Quick Documentation popup – it can now properly handle paragraphs, lists, and macros.

Completion improvements

In addition to improving the accuracy and speed of code completion, we’ve introduced two distinctive new capabilities. First, you can now autocomplete arguments in a single step, as long as appropriate values are present in the current scope:

Second, you can now apply a "static" function to an argument using the dot notation, which can be used in conjunction with algebraic data types (ADTs):

This functionality is a part of Hoogle Completion – our attempt to re-imagine Hoogle in a language that doesn’t use a Hindley-Milner type system (work in progress).

And more!

There are many more improvements that are included in the release. Your feedback is very welcome, as always. Feel free to ask any questions in the intellij-scala Gitter. Report any bugs to YouTrack.

Sincerely,
The IntelliJ Scala plugin team