Implement multiple languages in IntelliJ plugin

139 Views Asked by At

I'm currently writing an IntelliJ plugin. This plugin should handle HTML, Java (sometimes also JavaScript) and rythm (a template engine) I followed the plugin documentation of JetBrains.

My lexer (I use JFlex) matches everything and recognizes the matched code as HTML.

For the rythm code parts I have regular expressions in my lexer.

I also want to implement some Java Language features like the completion of packages and classes.

Also I don't know if my approach is correct. Because my lexer splits HTML at some points:

@, (, ), {, }

The regex to match the complete code and recognize it as HTML is:

TEXT = [^@*(){}]+

This regex causes the problem that my HTML Code is splitted at points where the code starts with @, (, ), {, and } If I don't except these characters my plugin doesn't reconize my other regular expressions and my brace matcher would not work anymore because it would match everything.

Is there a better way to support multiple languages and how do I implement Java language features in my plugin?

0

There are 0 best solutions below