Inject Java code within a xml file
Hi everyone,
I know IDEA support language injection out of the box. But how can I extend that support into a plugin? As an example In my xml file I have following tag
<u:java>
<![CDATA[
System.out.println("hello World");
]]>
</u:java>
I want to inject java language for that tag with a prefix and a suffix, so that when I type System.out. IDEA would show me autocompletion and other java specific functionalities. Thanks in advance.
Please sign in to leave a comment.
See com.intellij.lang.injection.MultiHostInjector for programmatic or EP "injectionConfig" from IntelliLang plugin for config-file based injection.
HI Yaan,
After creating a class implementing MultiHostInjector, from where should I call it? I mean do I have to add an extension point to the plugin.xml?
Yes, you will need to register it in your plugin.xml like
<extensions defaultExtensionNs="com.intellij">
<multiHostInjector implementation="com.intellij.struts2.freemarker.FreeMarkerCssInlineStyleInjector"/>
...
Btw there should be automatic "Unused" highlighting for extension points not mapped with automatic quickfix ;-)
Wonderful. Thanks Yann. You've been most helpful :)