IntelliJ IDEA 2020.2 EAP 5: Java 15, Related Problems, Intentions Preview, and More
This week we have lots of new features for you to try in our new IntelliJ IDEA 2020.2 EAP build! Here are the main highlights:
- Java 15 support
- Related problems
- Intentions preview
- Java intention actions improvements
- Structural Search and Replace inspections
- Improvements to completion and navigation in the build.gradle file
As usual, EAP builds for IntelliJ IDEA Ultimate are free to use, but they expire 30 days after the build date.
Java 15 support
The upcoming release of IntelliJ IDEA 2020.2 already supports Java 15, which is planned for release this September.
Java 15 will come with a Second Preview version of the Records feature. In Java 15, the Records specification has been slightly changed from the First Preview of this language feature that was introduced with Java 14. And we’ve updated our support for the Records feature accordingly.
The IDE now supports a new case for using the @Override annotation to declare that a method is an accessor method for a record component, so the ‘Missing @Override annotation’ inspection has been updated accordingly.
We’ve removed the requirement that canonical constructors be public. An access modifier must provide at least as much access as the record class. If a canonical constructor is implicitly declared, then its access modifier is the same as the record class.
The Second Preview for the Records feature now allows you to have Local Static Interfaces and Enum Classes. This means that when you choose Java 15 Preview as your language level, the IDE will no longer highlight it as an incorrect construct.
Java 15 will add Text Blocks as a standard language feature. The Text Blocks feature was introduced with Java 13, and IntelliJ IDEA has provided support for this feature since v2019.3. If you’d like to learn more about this feature, you can find more details about it in the blog.
IntelliJ IDEA 2020.2 will support preview features for both Java 14 and Java 15. Please note, however, that with v2020.3 we plan to drop support for the Java 14 preview features as IntelliJ IDEA 2020.3 will be released after the release of Java 15.
We’ve also added basic highlighting for sealed classes!
We’ll publish a more detailed blog about Java 15 and our support for this new version of Java soon. Keep an eye on our blog!
The upcoming IntelliJ IDEA 2020.2 now warns you with an inlay hint about problems in your Java code that are related to the signature change of a class or a method that has external usages. This feature works for fields as well.
Click on the related problems inlay hint, and the IDE will open the Find tool window with the list of problems occurring in the external files as a result of a member signature being changed.
In IntelliJ IDEA, it’s possible to preview the result of the intention actions and quick-fixes before you actually apply them to your code. Invoke Show Context Action with the Alt+Enter shortcut and select the required intention action, then preview the result by pressing Alt+Space on macOS and Ctrl+Shift+I on Windows and Linux.
We initially introduced this as an experimental feature with v2020.1. The upcoming IntelliJ IDEA 2020.2 polishes and refines it and adds more actions that can be previewed before being applied. The IDE also highlights the code that the action will delete with strikethrough formatting.
Java intention actions improvements
While we’re on the subject of intention actions, now is a good time to mention that we’ve added a new context action to collapse several statements into a loop.
We’ve also improved our ‘unroll loop’ intention action. It will get the loop size from dataflow and this action now supports enum.values().
There is also a new intention action that can duplicate statements into both ‘if’ branches. In some cases it’s reasonable to duplicate a part of code into both branches of the ‘if’ statement. Even though it could introduce code duplication, it can be very useful if you plan to refactor this piece of code further.
Structural Search and Replace inspections
In IntelliJ IDEA, you can create your own custom inspections and even a quick-fix using the Structural Search and Replace inspection.
The IDE will highlight the code pieces that match the Structural Search inspection you configured. If you configured a Structural Replace pattern, the IDE will also provide the quick-fix for the corresponding piece of code.
Previously you could only have one Structural Search and Replace inspection, which was not very convenient as you would need to change it every time you needed to look for a new particular type of code. Also, it wasn’t possible to have different descriptions, severities, and so on.
With the upcoming IntelliJ IDEA 2020.2, you can have as many Structural Search and Replace inspections as you want in your project, and for each inspection, you can specify the severity level or the description, or simply enable or disable the inspections separately.
You can create Structural Search inspections under Settings/Preferences | Editor | Inspections | General | Structural Search Inspection. Simply click the plus icon and select the type of inspection you want to create: Structural Search or Structural Replace. You can create this inspection from scratch or use one of the predefined templates.
The upcoming IntelliJ IDEA 2020.2 provides project name completion in the build.gradle files. What’s more, the IDE also provides navigation from a project name in the build.gradle files.
We’ve unbundled several plugins such as JBoss Seam, JBoss JBPM, ASP, OSGI, CFML Plugin, dmServer, Resin, Flash/Flex, Tapestry, Play Framework, GWT, and Struts 2. These plugins will be available in our plugin repository and can be installed manually.