void () { PsiFile file = configureByText(JavaFileType.INSTANCE, """ class A{ void bar() { abstract class Local { abstract void foo(); } int a = 1;while (true) { Local r = new Local() { public void foo() {} }}; }}"""); PsiAnonymousClass anon = SyntaxTraverser.psiTraverser(file).filter(PsiAnonymousClass.class).first(); PsiMethod method = anon.getMethods()[0]; PsiUtilCore.ensureValid(method); Arrays.stream(method.findSuperMethods()).forEach(PsiUtilCore::ensureValid); long javaCount = getJavaTracker().getModificationCount(); WriteCommandAction.runWriteCommandAction(getProject(), () -> { TextRange localRange = anon.getSuperClass().getTextRange(); getEditor().getDocument().deleteString(localRange.getStartOffset(), localRange.getEndOffset()); PsiDocumentManager.getInstance(myProject).commitDocument(getEditor().getDocument()); }); PsiUtilCore.ensureValid(method); Arrays.stream(method.findSuperMethods()).forEach(PsiUtilCore::ensureValid); assertFalse(javaCount == getJavaTracker().getModificationCount()); }