Posts Tagged ‘Language Injection’

Full-featured IntelliJ IDEA Editor for Injected Language Fragments

Tuesday, August 10th, 2010

You probably know about IntelliJ IDEA’s language injection feature. Right?

IntelliJ IDEA X takes it even further. Now you can edit fragments of code injected in literals in a designated full featured editor with all your changes immediately reflected in the original code.

You do not see all other code around the injected fragment. There’s no need to worry about code escaping. No modal popups. Just do what you need to. The fragment editor opens in a convenient split mode remembering your caret position and closes instantly when Esc is pressed.

The feature is available for any combination of injected language that IntelliJ IDEA supports, e.g. SQL in Java, HTML in JavaScript, and many others.

All the editor functionality including completion, code inspections, intention and code style actions is of course available in the fragment editor.

And a couple of examples. JPA QL fragment editor:

HTML fragment editor:

Your feedback is welcome!

User Defined Language Injection

Friday, March 20th, 2009

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.