IntelliJ IDEA scala type info

2019-02-09 00:55发布

问题:

The Eclipse scala plugin has a very nice info. One can hover over pretty much anything be it a function definition, val, var, function call etc and get type info. This is immensely useful to me to ensure type compatibility especially when I am trying new things out.

Is there a similar feature in IntelliJ Idea 12.1 (the latest version as of this comment)?

The closest thing I could find was the type info setting. The default key binding did not even work for me on Mac OS 10.7.5. Even after tweaking, it does not work as universally as it does in Eclipse which shows a type for pretty much everything. Has any one managed to get this to work? My ideal setting would be type info on hover just like in the Eclipse.

I have heard great things about the IntelliJ IDE for Scala but so far the Eclipse Scala plugin wins hands down.

回答1:

To enable on mouse hover type information go to Settings->Scala and select the "Show type info on mouse motion with delay" checkbox.



回答2:

Type Info is great in IntelliJ; you have to press the key shortcut to see the type of a given variable or function.

If I recall correctly, there's a conflict between Type Info's key shortcut and something else in IntelliJ. If you go to Settings -> Keymap -> Plug-ins -> Scala -> Type Info, double-click it, you'll see the conflicts. I changed mine to Option =. (see this answer for more tips if it still doesn't work)

Another shortcut I use quite a lot to quickly look up a definition is shift I.



回答3:

Not exactly what you're looking for but close enough - you can press alt + '=' when the cursor inside the function name, val name etc., and you will get popup with the type.



回答4:

Intellij IDEA 14 (OSX) has this option in the Preferences -> Languages and Frameworks -> Scala Compile Server menu option.

Ensure that the Show type info on mouse motion with delay option is ticked.



回答5:

I'm using Idea 13.0.2 with scala plugin 0.30.387 -- there is an option to display type info on hover just like eclipse. To turn it on, see

Preferences -> Scala