Sharing IElementTypes between languages

Hi

Our plugin includes a number of custom languages, with parsers derived from a common grammar (see this for details). Languages are intersecting, so current approach is to generate one mega-parser and subclass it by a number of language-specific parsers overriding parse_root_; this turned out to be the cleanest option.

It kind of works and IDEA recognizes two different file types with separate parsers. However I'm concerned about this: lexer is shared, and IElementType's takes Language instance as an argument. This means that AST node types shared by all the languages are only associated with one of them.

This is probably fine by me, I can account for it when using, say, PsiElementPattern.withLanguage. But I'm still concerned this can become a problem somewhere down the road.

Any advice, OK or a no-no?

Thanks

Please sign in to leave a comment.