The question, as stated, may not make sense, so here’s a concrete example:
I really only want the first string literal injected with JSON, but all string literals in that statement are being injected.
I’m showing the somewhat contrived example above in Java to confirm that this behavior happens in a general sense, but the actual motivating use case is from the language supported by my plugin which has added support for multiline strings with parameter substitution via a String.template(Map<String, Object>) mechanism, e.g.:
// language=json
String formatted =
'''
{
"Account": "${accountName}",
"Last Updated": "${date}"
}'''.template(new Map<String, Object>{
// These string literals are being treated as JSON as well
'accountName' => 'My Account',
'date' => Datetime.newInstance(2018, 11, 15)
});
This is going to be a very common idiom in the supported language, so breaking it up into two statements, one to declare and assign the multiline string and another to call template() on it, is going to result in unidiomatic code.
I know that the default language injector is just looking at the comment preceding the statement or even string literal expression and applying that language injection against all (accepting) language injection hosts in the statement. My question is whether it’s possible to veto some of those injections via an EP or something. Any insights?

