Is there a way to show the derived type of something in Intellij's Scala support?
For example if I am fumbling my way through some slick code and want to know what type the "user" val is perhaps by olding down a key and hovering my mouse that would be incredibly usefull.
DB.withSession { implicit session => val user = users.filter(user => user.email === email && user.password === password).first }
Any idea how to find out the type of "user" in my IDE as easily as possible?
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.
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.
In the Project tool window, right-click a Scala library class that you want to decompile. From the context menu, select Decompile Scala to Java. IntelliJ IDEA converts code to Java and opens the converted file in the editor. You can also open the library class in the editor and use its context menu for the conversion.
You can:
Alternatively, instead of just showing type info, you can show the documentation for the type. It will show the type even if there is no scaladoc or javadoc applicable.
In addition to @Cyäegha approach you can even tell idea to infer the type and add it for you.
On OS X, go on the variable, click alt + enter and you should see this
After you click on it you'll see
val test: String = "dsds"
The short key is at the voice Show Intention Actions.
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