void (final @NotNull Project project, @NotNull ProblemDescriptor descriptor) { addRemoveTestsScope(project, true); final VirtualFile vFile = descriptor.getPsiElement().getContainingFile().getVirtualFile(); UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(vFile) { @Override public void undo() { addRemoveTestsScope(project, false); } @Override public void redo() { addRemoveTestsScope(project, true); } }); }