void () { myFixture.configureByText("Survive.java", """ class Survive { String bar() { return "ba<caret>r.xml"; } \s }"""); assertNull(getInjectedReferences()); InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), new FileReferenceInjector()); PsiReference[] references = getInjectedReferences(); PsiReference reference = assertOneElement(references); assertTrue(reference instanceof FileReference); String textToReplace = "\"bar.xml\""; WriteCommandAction.runWriteCommandAction(getProject(), () -> { PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject()); Document document = manager.getDocument(getFile()); int start = document.getText().indexOf(textToReplace); document.replaceString(start, start + textToReplace.length(), "null"); manager.commitDocument(document); }); assertNull(getInjectedReferences()); }