Reputation: 39536
I have a Java 10 project with the following code:
Map<String, String> map = method();
When I put the cursor on Map...
and press Alt+Enter
, there should be an option "Replace explicit type with var
". However, this option is missing from my menu.
How to enable this option? Should I clean some caches or something?
I'm using IDEA 2018.1.1 EAP.
Upvotes: 1
Views: 3327
Reputation: 42223
In IntelliJ IDEA 2021.3, when auto-completing or when extracting a variable with ⌘ + ⌥ + v, there's a gear icon next to the generated variable.
Clicking the gear or using this shortcut ⌥ + ⇧ + o will bring a popup that allow to define the wanted behavior for this variable extraction and the next ones.
Adapt these shortcut to your active key map in IntelliJ.
Upvotes: 0
Reputation: 26462
The "Replace explicit type with 'var'" quick fix is provided by the Java | Java language level migration aids | Java 10 | Local variable type can be omitted
inspection. Please check if you have this inspection enabled in your settings. It is not enabled automatically if you have the "Disable new inspections by default" setting enabled.
Upvotes: 4