Cancel rename in handler

Hi!

I'm writing plugin which handles rename refactoring of Idea and refactors corresponding resourses. But in some cases such refactoring may lead to the inconsistent state and I want to cancel rename refactoring.
I'm using RefactoringElementListenerProvider

I read this post http://devnet.jetbrains.net/message/5213549#5213549 where was said that it's impossible but may be something was changed since 2008?

4 comments
Comment actions Permalink

You can try to throw AbnormalCommandTerminationException from your rename handler. If the user experience that you get when doing so is not good enough for you, I'm afraid we still don't have a better solution.

0
Comment actions Permalink

Thanx. But it has no effect. The element is being renamed anyway.

0
Comment actions Permalink

Ah, right. No, there is no way to cancel rename from a rename listener.

0
Comment actions Permalink

Hi everyone

Has the situation changed since 2012? It seems some conditions prevent the renaming action from being executed (for example "Selected class is not located inside project."), but I didn't find how to add my custom conditions (like "function declaration is in a generated file").

At the moment, I throw an IncorrectOperationException in PsiReference. handleElementRename(), which shows a popup after the user has validated the new name. I would really like to be able to cancel the refactoring even before starting it.

0

Please sign in to leave a comment.