User Defined Language Injection

In IntelliJ IDEA you can quickly configure language injection for XML tags, attributes and Java method parameters and their return values. Just use Inject Language Intention on the code like this:

and it will immediately turn to:

And you get the complete coding assistance, with syntax and error highlighting, completion and navigation.

This functionality is provided by the bundled IntelliLang plugin. The full configuration is available for edit in the Settings dialog (see screenshot below). Default configuration includes various mappings like RegExp language in Pattern.compile(), SQL in JDBC API calls, JPA & Hibernate QL injections and much more.

Comments below can no longer be edited.

5 Responses to User Defined Language Injection

  1. Avatar

    Piotr Gabryanczyk says:

    June 16, 2009

    I just realised how powerfull this feature can be. It can enable writing libraries like closures (http://code.google.com/p/closures). Which let you using easily embeded dynamic languages like groovy or jruby inside of JVM almost seemlesly.

  2. Avatar

    Volker Mosthaf says:

    September 10, 2009

    Is the annotations.jar only required for compilation or also during execution?
    If it is necessary at runtime, can the jar be freely distributed along with applications created by idea?

  3. Avatar

    Ashwin Jayaprakash says:

    September 2, 2010

    How come we’ve never heard of this before? Talk of hidden gems

  4. Avatar

    Matthew Pocock says:

    November 2, 2010

    The language injection feature is awesome. However, right now languages can only be injected into a couple of host languages (xml, java?). I work mainly in scala, and would love to be able to inject languages into strings in my scala code.

  5. Avatar

    Fabián López says:

    March 4, 2015

    Is this only available for intellij idea ultimate? I can’t seem to make it work on community edition

Discover more