Prevent from deleting a PsiFileSystemItem

已回答

I have a PsiFileSystemItem class that overrides the ‘delete’ and ‘checkDelete’ method as below. Though it prompt error message, it still be deleted from disk. How to prevent deleting?

public class MyClass implements PsiFileSystemItem {
    @Override
    public void delete() throws IncorrectOperationException {
        throw new UnsupportedOperationException("Cannot delete");
    }

    @Override
    public void checkDelete() throws IncorrectOperationException {
        throw new UnsupportedOperationException("Cannot delete");
    }
}

 

0

Hi,

Please provide a minimal reproducible sample, a project we can test it on, and steps to reproduce.

0

请先登录再写评论。