void () { new MyTestInjector(getPsiManager()).injectAll(myFixture.getTestRootDisposable()); myFixture.configureByText("a.java", "class X { String java=\"class <caret>Foo {}\"}"); PsiClass cls = (PsiClass)myFixture.getElementAtCaret(); assertEquals("Foo", cls.getName()); PsiAnchor anchor = PsiAnchor.create(cls); myFixture.type('\n'); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); anchor.retrieve(); // file is changed, so we probably can't restore. But this call shouldn't throw exceptions. }