RBS
RubyMine supports the RBS language to describe the types used in Ruby programs. RubyMine recognizes .rbs files and provides the following coding assistance:
Error and syntax highlighting
Code commenting using Ctrl+/
RBS type signatures
RubyMine supports RBS type signatures and uses them to infer the type of Ruby elements. This helps you to experience the better code insight when developing your code in Ruby.
If you have RBS files in your project, RubyMine provides:
Better method name completion
RubyMine displays methods from appropriate classes at the beginning of the list, when invoking code completion.
Improved navigation actions
When you invoke the 'Go to declaration' action, RubyMine navigates you to the exact declaration instead of providing a list of declarations to choose from.
Search for usages of the corresponding declaration
With RBS types, RubyMine can find the correct declaration of a Ruby element. When you invoke the 'Find usages' action, RubyMine instantly finds usages of the corresponding declaration instead of giving you a list of declarations to choose from.
Consistent rename refactorings
RubyMine finds all usages of a particular Ruby element that you are renaming. After invoking the 'Find usages' action, there will be fewer references marked as 'Untyped (potential) usages'.
Installation
If you use earlier versions of Ruby, add the following line to your Gemfile
:
The rbs
gem provides a set of built-in type signatures for the standard libraries out-of-the-box. When you use rbs
in your project, RubyMine displays its sources in external libraries.
Create an RBS file
In the Project view Alt+1, select the directory where you want to create a new RBS file.
Press Alt+Insert and select RBS File/Class from the popup.
As another option, select
from the main menu.Specify the filename and press Enter.
Configure code style settings
RubyMine applies the same code style settings for both Ruby and RBS. To customize code style settings for RBS:
In the Settings/Preferences dialog Ctrl+Alt+S, go to .
Configure the desired code style settings.
Configure syntax highlighting
RubyMine uses the Ruby color scheme to highlight the syntax in RBS files.
You can configure RBS-aware syntax highlighting according to your preferences and habits.
In the Settings/Preferences dialog Ctrl+Alt+S, go to .
Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configure colors and fonts.