void () { myFixture.configureByText("Foo.java", """ class Foo { String bar() { String result = "{\\"a<caret>\\" : 1}"; return result; } \s }"""); PsiLanguageInjectionHost injectionHost = myFixture.findElementByText("\"{\\\"a\\\" : 1}\"", PsiLanguageInjectionHost.class); SmartPsiElementPointer<PsiLanguageInjectionHost> hostPtr = SmartPointerManager.createPointer(injectionHost); StoringFixPresenter storedFix = new StoringFixPresenter(); InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), Injectable.fromLanguage(Language.findLanguageByID("JSON")), storedFix); myFixture.checkResult(""" class Foo { String bar() { String result = "{\\"a\\" : 1}"; return result; } \s }"""); assertInjectedLangAtCaret("JSON"); storedFix.process(hostPtr.getElement()); myFixture.checkResult(""" import org.intellij.lang.annotations.Language; class Foo { String bar() { @Language("JSON") String result = "{\\"a\\" : 1}"; return result; } \s }"""); assertInjectedLangAtCaret("JSON"); UnInjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile()); assertInjectedLangAtCaret(null); }