Intention Actions in RubyMine

RubyMine provides you with a set of intention actions that can help you to quickly fix code smells, convert statements for better code style, add strings to locale dictionaries, use language injections, and do other handy things simply by pressing Alt+Enter. Let’s review all the basic and new intention actions added in RubyMine 2018.3 EAP.

Quick Overview

Let’s start with some basic exaxmples:

Below is a two-line statement that uses a ternary operator. You can easily convert it to an if...end clause, which is considered preferable for multiline statements. Just put the caret anywhere inside the statement, and press Alt+Enter:

That’s it! Note that you can rollback this change by pressing Alt+Enter again and choosing the other opposite option.

Syntax changes in the newer Ruby versions are another reason you may need to frequently use RubyMine intentions. For instance, you can quickly replace hash rockets with colons when assigning key-value pairs in hashes, to make it look a bit more up-to-date:

Some intentions may even have nothing to do with Ruby or Rails. For example, there’s an intention that will allow you to quickly check regular expressions:

There are many more intentions for Ruby, Rails, JavaScript, and other languages and technologies in the settings. You can always review them, check the examples, and/or turn off the ones that you don’t need in the settings (Preferences / Settings | Editor | Intentions):

New intentions in RubyMine

Let’s now take a look at some of the fresh intentions added in RubyMine 2018.3 EAP.

First of all, we’ve added a De Morgan’s law intention, to help you improve some ugly negations:

Another new intention that allows you to extract block calls to methods:

With v2018.3 EAP, you can also quickly insert a missing end for classes, modules, and methods:

Finally, you can now quickly flip binary expressions:

Get the latest RubyMine 2018.3 EAP build to try this, and all the other new features out. Should you face any issues, please report them to our bug tracker.

Cheers,

Your RubyMine Team

This entry was posted in Feature, WhatsMining and tagged , . Bookmark the permalink.

Leave a Reply

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