New intentions for Scala

Intentions were extended with several new.

  • Now you can simply switch between two different ways of writing expressions – infix and method call. Convert infix notation to method call (and vice versa) intention provides you this possibility. It appears when you put caret to the operation in your statement.


Result:

  • Intention for removing unnecessary ‘apply’ simplifies your code.


Result:

But in some cases it’s impossible to do this action. So, you will see error hint, which explains you reasons of rejecting your action. For example:


  • Now you are able to introduce explicit parameters in anonymous function (and vice versa). Sometimes you meet with situations, when you write function with implicit parameters, but then realize that you  must add new parameters or do something else that is impossible to do with implicit parameters. This intention provides you possibility to replace your infix expression with function expression. If you put caret near the placeholder you will be able to use this intention.

After converting you can change parameters names:

Also you can perform reverse converting. But in some cases it is impossible to refactor this authomatically, because of, for example, incorrect order of parameters usages. So you will see error hint with explanations.

  • Replace ‘==’ with ‘equals’ and replace ‘equals’ with ‘==’ intentions work both in infix and method call expressions. You should put your caret into ‘==’ or ‘equals’.

  • Swap operands intention swaps the operands of a comparison expression. It works with all following operators: ‘<’, ‘>’, ‘<=’, ‘>=’, ‘!=’, ‘==’, ‘eq’, ‘ne’, ‘equals’ and both in infix and method call expressions.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to New intentions for Scala

  1. OlegYch says:

    Awesome, thanks!

  2. Hugo Sereno Ferreira says:

    Nice… When will this be available? :)

  3. OlegYch says:

    @Hugo it’s available in nightly

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>