void (VirtualFile virtualFile) { PsiJavaFile psiX = (PsiJavaFile)myPsiManager.findFile(virtualFile); final PsiClass xClass = psiX.getClasses()[0]; CommandProcessor.getInstance().executeCommand(getProject(), () -> WriteCommandAction.runWriteCommandAction(null, () -> { try { xClass.getMethods()[0].delete(); } catch (IncorrectOperationException e) { LOG.error(e); } }), null, null); myWolfTheProblemSolver.waitForFilesQueuedForInvalidationAreProcessed(); }