void () { @Language("JAVA") String text = "class C1{}\nclass C2 {}"; PsiJavaFile file = (PsiJavaFile)configureByText(JavaFileType.INSTANCE, text); SmartPsiElementPointer<PsiClass> pointer = createPointer(file.getClasses()[1]); gcPointerCache(pointer); ApplicationManager.getApplication().runWriteAction(() -> file.getClasses()[0].delete()); assertNotNull(pointer.getElement()); }