How to embed language for xml tag?

Answered

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.

 

<wxs>

let a = 1;

class A {

}

class B {

}
</wxs>

 

3 comments
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 MultiHostInjector.java for more details.

0
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

 

0
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.

0

Please sign in to leave a comment.