Skip to end of metadata
Go to start of metadata

The license could not be verified: License Certificate has expired!

IntelliJ IDEA offers an easy way to work with type inference feature such as Scala Show Type Info action.

 

1. Enter Code 

Let's enter a random code and see what can be done:  
  
 

2. Invoke Show Type Info Action 

Icon

If you select Show type info on mouse motion check box inSettingsIDE SettingsScala, then in the Editor, you can simply navigate with the mouse to a value to see its type information.

To invoke Show Type Info action in Editor, navigate to the value and pressAlt+= (Ctrl+Shift+P for Mac): 
 

You can also see the type information on a value definition. Simply put the caret on a value definition and pressAlt+= (Ctrl+Shift+P for Mac):

3. Add Type Annotation 

To add a type annotation, highlight the value and pressAlt+Enter:

As a result, the type annotation is added:

 

4. Remove Type Annotation

You can also remove the type annotation the same way you have added it, by pressingAlt+Enter:

 

5. See Type Annotation on Expression

To see the type information on an expression, simply  navigate to the expression, highlight it and  pressAlt+= (Ctrl+Shift+P for Mac):


 

  • No labels

5 Comments

  1. Anonymous

    Please add a keyboard shortcut for adding the type annotation!

  2. Anonymous

    I can see type info with ctrl+shift+p but alt+enter does not add type; it brings up "adjust code style settings". Intellij 15.0 CE

    1. Hi there,

      could you please send us an example of your code to see in what case you get this option instead of the one you're suppose to.

      1. Anonymous

        Just saw this. Fixed by upgrading to 15.0.2