IntelliJ IDEA 2016.3 Help

Working with Scala Show Type Info Action

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

Entering code

  • Let's enter a random code and see what can be done:
    /help/img/idea/2016.3/type_info_code.png

Invoking Show Type Info Action

  • If you select Show type info on mouse hover after, ms check box in Settings | Languages and Frameworks | Scala, 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 press Alt+Equals:
    /help/img/idea/2016.3/type_info_string.png
  • You can also see the type information on a value definition. Simply put the caret on a value definition and press Alt+Equals:
    /help/img/idea/2016.3/type_info_int.png

Adding Type Annotation

  • To add a type annotation, highlight the value and press Alt+Enter:
    /help/img/idea/2016.3/type_info_add.png
    As a result, the type annotation is added:
    /help/img/idea/2016.3/type_info_add_result.png
  • You can also use Adjust types action to shorten types with full qualified names.
    /help/img/idea/2016.3/type_adjust.png
    In this case the necessary imports are added.
    /help/img/idea/2016.3/type_adjust_result.png

Removing Type Annotation

  • You can also remove the type annotation the same way you have added it, by pressing Alt+Enter:
    /help/img/idea/2016.3/type_info_remove.png

Seeing Type Annotation on Expression

  • To see the type information on an expression, simply navigate to the expression, highlight it and press Alt+Equals:
    /help/img/idea/2016.3/type_info_expression.png
Last modified: 29 November 2016