My plugin's custom language supports an integrated query language that can be used both statically and dynamically. Dynamic usage takes place via strings, typically a concatenation of string literals and other string expressions to parameterize the query, e.g.:
List<User> users = Database.query('SELECT Id, Username FROM User WHERE Username LIKE \'' + usernamePattern + '\'');
I've managed to implement PsiLanguageInjectionHost for my language's string literals and have registered a LanguageInjector implementation to inject the query language when found in the correct context. Now I get the desired behavior when the argument to Database.query() is a single string literal, but it doesn't work properly when the argument is a concatenation.
When I inject SQL into concatenations of Java string literals it treats the full concatenation as a single expression in the injected language, so there must be some way to make this work. Any tips on how that happens? I can see a notion of Shred in PsiLanguageInjectionHost but don't know if that's potentially useful.
Thanks in advance for any insights!