How do I activate type annotations hints in Kotlin

2020-05-20 04:14发布

问题:

I was able to activate this option once in my MacOS intellij version, but could never find this option anymore, I forgot its name.

I know there is the CTRL+SHIFT+P alternative to this, but it is not as user-friendly.

How can I activate the option to make intellij show me all the inferred types like depicted? This screenshot came out of the intellij where I was able to put it showing "type hints" like this, so it is possible. I just don't remember where to find this option anymore so I can activate in all my other intellij's.

回答1:

Go to Settings -> Editor -> General -> Appearance -> "Show parameter name hints" -> Configure... -> Language: Kotlin -> Options -> "Show local variable type hints".

In newer Versions of IntelliJ (at least from 2019.3.1 onwards) it is located at: Settings -> Editor -> Inlay Hints -> Kotlin -> "Show parameter hints" (thanks to @zero).

I think you are allowed to say, that this feature configuration is a little bit hidden in the menues.



回答2:

Adding to @Simulant answer.

In Latest Version of IntelliJ (2019.3.1) , You will NOT find this in Settings -> Editor -> General -> Appearance -> "Show parameter name hints"

Its available in Settings -> Editor -> Inlay Hints -> Kotlin -> "Show parameter hints"