IntelliJ shows type hints for local variables in Kotlin as shown here:
This makes it easy to see the type of variables even if their types are inferred.
Java 10 introduces type inference for Java with the var
keyword.
However, IntelliJ does not show any type hints by default:
After searching the internet for a bit, I was unable to find any information on how to enable type hints for local variables for Java. Is this even possible currently?
I use IntelliJ Community Edition 2019.1 on Windows 10.
View parameter hints in the editorOpen the Settings/Preferences dialog ( Ctrl+Alt+S ) and go to Editor | Inlay Hints | <required language>. Select Parameter hints from the list, make sure the Show parameter hints checkbox is selected, and then specify the context where you want parameter hints shown.
To navigate to the code where the variable is declared, right-click a variable and select Jump to Source F4 . To navigate to the class declaration of the variable type, right-click a variable and select Jump to Type Source F4 .
IDEA doesn’t have this feature yet. You can raise a feature request at https://youtrack.jetbrains.com/issues/IDEA.
In the latest version of IntelliJ (2020.3) these are called "Inlay Hints"
Preferences/Editor/Inlay Hints
The closest feature in Java is Replace 'var' with inferred type
:
Settings -> Editor -> General -> Code Folding -> Replace 'var' with inferred type
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With