Improved IDE Performance, New Editor Inline Hints, and More for Kotlin in the Latest IntelliJ IDEA
Enjoy a better debugging experience, improved IDE performance, new editor inline hints for ranges and chain calls, and more improvements for Kotlin in IntelliJ IDEA 2021.3:
- A better debugging experience, including inline stack frames, and smart step into.
- IDE performance improvements, including faster declaration searches.
- New editor inline hints for ranges and chain calls.
- New refactorings and improved inspections and intentions.
- Other IDE improvements.
Auto-update to this new release
IntelliJ IDEA will give you the option to automatically update to the new release as soon as it is available.
If you are not yet an IntelliJ IDEA user, you can download the latest version here.
Better debugger experience
IntelliJ IDEA 2021.3 brings an improved debugger that works better with inline functions, has a smarter Step Into action, and works faster with coroutines.
Inline stack frames
The debugger can now detect Kotlin inline functions and show inline function calls in the stack trace panel. You can navigate to these calls and inspect and evaluate the variables of each frame.
Smart Step Into
The latest IntelliJ IDEA comes with the new Smart Step into action, which makes the debugging process more predictable. It allows you to stop at any child function when one line of Kotlin code calls several methods.
When you find yourself at a line with more than one method call, just click the Step Into button located in the top pane of the Debug tool window, or use the F7 shortcut. The IDE will then highlight the places where you can step into the code, and you’ll be able to select the line you want by clicking on it.
This feature is available by default. If you want to disable this default behavior for the Step Into action, go to Preferences / Settings | Build, Execution, Deployment | Debugger | Stepping | Kotlin and deselect the Always do smart step into checkbox. If you do so, the Smart Step Into action will still be available via the ⇧ F7 shortcut on macOS or Shift+F7 on Windows and Linux.
Coroutines debugger speed-up
The Coroutine debugger now calculates information about coroutines much faster. We did some research and found a way to optimize calls to JVM Debugger. Now the coroutine panel will load instantly, even if there are a lot of coroutines. Thanks to this change, it has become much more comfortable to use the coroutine debugger in sessions with a remote client.
IntelliJ IDEA 2021.3 brings some major performance improvements for Kotlin. Besides a bunch of fixes for freezes and IDE slowdowns, it also comes with a compiler reference index, which significantly improves the speed of the “Find Usages” action and a built-in cache recovery troubleshooting tool designed to solve problems related to cache inconsistencies without requiring complete cache invalidation.
Compiler Reference Index
The new compiler index reference allows you to find declaration usages much faster. Using the information from the compiler, the search is performed only in files that actually use the declaration you are looking for, and not in all possible files. The more common the declaration name, the more effective the optimization is. The new compiler index reference also improves the search for declarations that have implicit calls (like Data Classes, as they generate `componentN` functions that are used in destructive declaration). Here’s an example of how this new feature improves the performance of “Find Usages” with and without a compiler index for an IntelliJ-community project on a Linux agent for different declarations:
The Compiler Reference Index feature is available for Maven and IntelliJ built-in build systems.
Cache recovery is a useful built-in troubleshooting tool that has been introduced to solve problems related to cache inconsistencies without requiring complete cache invalidation when possible. The new Run Guided Cache Recovery… action offers two main advantages compared to Invalidate Caches: Run Guided Cache Recovery… : it can be performed per project, and it’s faster.
The action consists of a sequence of several actions, with the ability to stop after each of them. Each action will take less time than reindexing and will not lead to the loss of caches for other projects. The final action – Invalidate Caches and Restart – will reboot the IDE. After each action is performed, the user will be shown a notification with the option to abort the cache recovery process or perform the next step. The action can be invoked right from the main menu.
Editor inline hints
IntelliJ IDEA 2021.3 comes with new editor inline hints for ranges, chain calls, and VCS changes.
Inline hints for ranges
With the new IntelliJ IDEA it has become much easier to interpret range bounds, as it comes with new inline hints that explain with plain mathematical signs what the words or symbols used for the ranges mean:
This feature is enabled by default. If you want to switch it off, right-click on a hint and select Disable ‘Ranges’ hints type or go to Preferences / Settings | Editor | Inline hints | Kotlin | Ranges and deselect the Show ranges checkbox there.
IntelliJ IDEA 2021.3 displays type hints for long method chains. Previously, these hints were available only for Java, but now they work with Kotlin as well. It is especially useful to see the type of each call as a type hint for long method chains with generics. For simple builders where the type is obvious, the IDE will hide the type hint.
New refactorings and improved inspections and intentions
IntelliJ IDEA 2021.3 comes with a new extract constant refactoring, and Constant conditions inspection. It also brings an improved Possibly blocking call in non-blocking context inspection and improved intention preview.
Extract constant refactoring
A new refactoring allows you to extract constants in Kotlin. To use it, put the caret on a string and press ⌥⌘C on macOS or Ctrl+Alt+C on Windows and Linux.
Constant conditions inspection
With the help of new Constant conditions inspection, IntelliJ IDEA can report non-trivial conditions and values that are statically known to be always true, false, null, or zero. This inspection tracks and warns you about bugs that should be fixed and redundant code.
You can find this inspection in Preferences / Settings | Editor | Inspections | Kotlin | Probable bugs.
Improved intention preview
IntelliJ IDEA 2021.3 comes with an improved intention preview. Now it:
- works for more intention actions and quick-fixes in Kotlin.
- displays informative HTML descriptions for intention actions which are impossible to show a preview for.
- partially shows the possible outcomes for an action that modifies several files.
Improved Possibly blocking call in non-blocking context inspection
The Possibly blocking call in non-blocking context inspection warns you if you use a coroutine in the wrong context. The new IntelliJ IDEA comes with an improved version of this inspection that covers more cases so you can customize to work better in your particular environment. It is now possible for the inspection to prompt you about the problem and offer a context-dependent quick-fix.
IntelliJ IDEA 2021.3 also brings more IDE features that improve the Kotlin experience. You can read more about them in the related IntelliJ IDEA EAP blog posts:
- Kotlin 1.6 Support in IntelliJ IDEA 2021.3 – blog post
- What’s new in IntelliJ IDEA 2021.3 – docs
- What’s new for Kotlin in IntelliJ IDEA 2021.2 – blog post