Scala Plugin
Scala Plugin for IntelliJ IDEA and Android Studio
IntelliJ Scala Plugin 2023.3 Is Out!
Scala 3
As usual, the new release focused much on improving the Scala 3 support. Especially enums received much attention. The Scala plugin now recognizes that enums cannot be extended and highlights such attempts; annotations and modifiers are now propagated correctly to generated symbols; type widening of apply methods is fixed to take only direct supers into account; and some false error highlighting due to duplicate synthetic elements were fixed. Auto-completion for enums works better now as well.
Another thing we worked on is better analysis of Scala 3 code and getting rid of invalid error highlighting which sometimes appeared in semi-random situations, often when the code in question touched other files. Also, until now, IntelliJ Scala Plugin sometimes got confused with given
s. In the 2023.3 release, this issue is over: the “Go to declaration” action executed on a given import works properly, and the automatically generated names assigned to givens are the same in the plugin as in the compiler.
On top of that, the support for inline parameter modifiers has been improved – they are now correctly highlighted in the code and displayed in the Parameter Info window.
Inlay hints
Inlay hints in IntelliJ IDEA are visual cues placed directly within the editor’s code. They provide contextual information to make the code more readable and comprehensible without modifying the actual source code. These hints can be valuable, especially in languages like Scala, where the type inference system might lead to concise code that is occasionally difficult to decipher at a glance.
In the new release, we reworked the inlay hints settings to make it more straightforward to see the types of inlay hints and how to use them. The hints are now aligned and shifted to the right of the screen, not getting in the way of your code.
The X-Ray Mode
Inlay hints, and other information displayed directly in the editor, next to the code can improve readability and greatly help the developer. But such functionality comes at a price. Readability is a subjective issue, and instead of appreciating the help, you may feel that the editor is now too crowded and cluttered with unnecessary text. You may decide to turn it off. But then, it may happen that your work takes you to a place you don’t know so well, and now additional information displayed directly in the editor could be helpful again. So you need to go to the settings and re-enable it.
Now, with X-Ray, you can keep inlay hints and all the other additional information disabled or only partially enabled to the point where you feel comfortable, and then press down the Control / Command button two times and hold it – all the other hints will appear, and will be displayed only for the length of time you keep Control / Command down.
Syntax highlighting
On the syntax highlighting front, we worked on better detection of unreachable code and false positive red code. The plugin now correctly recognizes code used in places around thrown exceptions and try/catch/finally
blocks, and it considers the existence of implicit imports. Also, “unused declaration” and “the method can be private” inspections can now be suppressed for non-standard Scala files, such as worksheets.
User Interface Improvements
In this release, some of our work on IntelliJ Scala Plugin went into making it easier to navigate the UI. The Scala settings are now easier to find through the text search. The Parameter Info window now only shows whether a parameter has a default argument but not the exact expression, which improves readability. In the “Find Usages” window, you can now click the “File structure” button and see more information about the usage of a given element. For the same reason of better readability, in the Structure View, you can now see that we display ?=>
to distinguish implicit parameters from regular ones, as both writing implicit
or using
and not writing anything would be less readable. Besides, we’ve introduced new icons in the Structure View and the Project View for runnable objects, test classes, exception classes, and enums.
sbt
From now on, the Scala plugin calculates all project transitive dependencies during reload/import. Before, only direct project dependencies were calculated, and the transitive ones were added as the dependencies of the direct dependencies, which sometimes led to situations when some project dependency that should not be a dependency for a project being taken into account. The new logic gives us more control over project dependencies and allows us to avoid that.
In multi-module projects, we’ve fixed the issue where an sbt module could incorrectly depend on the Scala SDK instead of the standard Scala library, as well as some issues related to sbt commands history being disrupted upon importing or reloading sbt projects. Actions related to reloading BSP and sbt are now made more accessible for you to find and use.
Also, we improved the process of fetching available Scala and SBT versions during new project creation. It has now been made cancelable and asynchronous, significantly speeding up the workflow. We’ve also resolved issues related to hanging when running or importing a project via sbt shell with sbt version 1.8.2 or newer on Windows.
Besides, in this release we drop support for the sbt-android plugin.
“Using” directives
“Using” directives can now be auto-completed, and their elements are automatically formatted and highlighted correctly. Besides, if you now auto-import a symbol, it will be added to the file under the “using” directives, resulting in cleaner and more organized code.
As always, your feedback is very welcome. Please report any issues you find to YouTrack. If you have any questions, feel free to ask us on Discord.
Happy developing!
The IntelliJ Scala plugin team