How to embed language for xml tag?


I am maintaining a plug-in. One of the functions is to provide editing of the wxml file. This file is very similar to the xml file and contains many unique tags, but does not include the tags that come with html. I am currently looking for a way to embed js language in xml tags.



let a = 1;

class A {


class B {



Comment actions Permalink

You should implement the <multiHostInjector> extension point to inject another language within the XML file. From JavaDocs:

* Performs language injection inside other PSI elements.
* E.g. inject SQL inside XML tag text or inject RegExp into Java string literals.
* These injected fragments are treated by the IDE as separate tiny files in a specific language and all corresponding code insight features
* (completion, highlighting, navigation) become available there.

Check the for more details.

Comment actions Permalink

Thanks you for your reply.

I use <multiHostInjector> solved this, But I have a question, in HtmlLexer,  Why Html's <script> and <style> are implemented at the Lexer level


Comment actions Permalink

I guess because of the performance. In case you're not providing full language support but extending the existing one - it's required to go with injectors.


Please sign in to leave a comment.