Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view the type of a scala expression in IntelliJ

People also ask

How do I get Scala class in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.

How do I get Scala 3 in IntelliJ?

Trying the nightly builds is easy:Open Settings | Languages | Scala | Updates. Select Nightly plugin update channel and press Check for updates (you can always select EAP or Release to revert to a more stable build; alternatively, you can download any Scala plugin build from the Plugin Repository).

How do I get Scala interpreter in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.


Select expression and type Alt + =.


If you want to change the shortcut go to Preferences > Keymap and enter "Type Info" in the search field.

In older versions, it's Shift + Ctrl + Alt + T.


On OS X, it's ctrl + shift + P for me. This shows the exact type with resolved generics.


CTRL / Command key and hover over the variable or method.


You can hit Ctrl + Q on a variable or method signature to view its type.

There is also a neat trick to view type of any expression: select the expression and type Ctrl + Alt + V. This will show Extract variable dialog with expression type to be extracted shown for convenience.


You can set IntelliJ up sort of like eclipse. Go to:

File -> Settings -> Languages & Frameworks -> Scala

and then tick "Show type info on mouse hover after, ms" and set your preferred timeout.

This works well except that other messages seem to take preference. The most common being "Declaration is never used" which is quite a lot of the time if you have just written a val and want to see it's type. Then you have to resort to (Alt + =) for PC or (Ctrl + Shift + P) forMac.