RubyMine 2017.2 Help

Using language injections in SQL

For language injections in SQL, RubyMine provides the following additional features (for general info, see Using Language Injections):

Using auto-injection for XML and JSON

For values defined as XML and JSON types, the corresponding languages are injected automatically.


  1. Create an SQL file and open it in the editor.
  2. Specify PostgreSQL as an SQL dialect for that file.
  3. Copy the following into your SQL file:
    CREATE TABLE test ( my_xml XML DEFAULT '' );
  4. Place the cursor between the quotation marks.
  5. Check the light bulb menu (Alt+Enter): there is the Edit XML Fragment command there which means that XML has been auto-injected.

Using pattern-based injections for user-defined data types

You can create patterns - e.g. for user-defined data types - and associate those patterns with languages. As a result, RubyMine, when it comes across a data type that matches the pattern, will inject the language specified for that pattern.

In the following example, we'll create a pattern for a data type ending in DATA and associate that pattern with XML.


  1. In your SQL file, replace XML with MYDATA.
  2. Place the cursor between the quotation marks.
  3. Press Alt+Enter. Note that there is no more Edit XML Fragment command in the menu.

    Select Inject by Type, and then select XML (XML files).

  4. In the dialog that opens, in the Type pattern field, specify (?i).*DATA. (The type patterns are specified using regular expressions. In this example, (?i) turns the case-insensitive mode on; .* stands for any number of any characters.)
  5. Check the light bulb menu again (Alt+Enter). The Edit XML Fragment command has become available which means that XML has been injected for the value of the MYDATA type.
  6. To remove the pattern you have just created (if you don't need it), open the Settings / Preferences dialog (e.g. Ctrl+Alt+S), go to the Editor | Language Injections page, find and delete the pattern.

See Also

Last modified: 21 July 2017