Is there any way to stop language injection in chained calls?

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?

Unfortunately there is no such vetoer, but you could contribute one if needed.

FYI, there actually is an EP for exactly this in 2025.3+, though it’s currently annotated as @ApiStatus.Experimental.

The EP is org.intellij.intelliLang.fallbackInjectorSuppressor, and the EP interface is org.intellij.plugins.intelliLang.inject.FallbackInjectorSuppressor. The primary documented use case is more around split mode and managing conflicting injections across the split, but it actually works very nicely for my use case.

Here’s the original example from above showing a JSON-injected multiline string with parameter substitution via a map of name-keyed values where my plugin suppresses the top-level explicit injection for all map keys and any map values that don’t have their own “local” explicit injection, e.g., the value for accountName:

I don’t know if anyone else is going to need this particular EP, but just in case, I wanted to circle back and share the solution that I found.