Code injection in xml not showing
Hi, I'm working on some custom injection.
What i would like to inject is some groovy in the following structure (after groovy keyword) for example:
<set field="placeholderValues.fromDate" value="${groovy:nowTimestamp.toString()}"/>
From what i read from the doc, for simple injection no code is needed, only config, so i have this :
in plugin.xml file:
<depends config-file="xml-injections.xml">org.intellij.intelliLang</depends>
in a xml-injection.xml file :
<idea-plugin>
<extensions defaultExtensionNs="org.intellij.intelliLang">
<injectionConfig config="OfbizGroovyInjections.xml"/>
</extensions>
</idea-plugin>
and in OfbizGroovyInjections.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<component name="LanguageInjectionConfiguration">
<injection language="Groovy" injector-id="xml">
<display-name>OFBiz groovy injection</display-name>
<single-file value="false"/>
<prefix>${groovy:</prefix>
<suffix>}</suffix>
<place><![CDATA[
xmlAttribute().withValue(string().contains("{groovy:"))
]]></place>
</injection>
</component>
The injection shows up in the dev instance with the right pattern, but for some reason it doesn't seem to actualy inject anything.
Am i missing something obvious here ?
Or do i need to implement a LangageInjector (though i seems a bit overkilled for simple injection)
I oppened a slack topic about this (got no answer yet though):
https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1675246191149869
Any help is welcome !
Please sign in to leave a comment.
Please try the following:
1) specify exact pattern/name for xmlAttribute() (and its parent tag(s))
2) try using `<value-pattern>` instead of the `contains()...` condition for matching the element
See https://github.com/JetBrains/intellij-community/blob/idea/223.8617.56/plugins/IntelliLang/xml-support/resources/xmlInjections-html.xml as sample.
Thanks Yann, it worked with :