Prevent rename refactoring
I'm defining references and usages for my custom language plugin. Since I cannot rename those consistently I would like to disable the "rename refactoring" operation for these elements.
My initial approach was to have
isMemberInplaceRenameAvailable
return false, but this only prevents inline editing, not renaming in general. I still get a popup and default renaming.
My second guess was to implement a specific
RenamePsiElementProcessor
but there seems to be no method that decides on renaming or not.
What's the proposed way of disabling rename refactoring? (Merely ignoring the rename operation in <element>.setName() seems broken.)
Lars
请先登录再写评论。
The easiest solution is to use the <vetoRenameCondition> extension point. Extensions for this EP are implementations of Condition<PsiElement> that return true if renaming the element should be forbidden.
Hello Lars,
multiple RenameHandler's can be defined. Custom handlers are iterated until in one of them
Thanks, very simple and works beautifully.
For the benefit of others, here's some example code: link
And here's the list of extension points, seems there's an extension for everything: link (scroll down to "How to Get the Extension Points List?")
Lars
Thanks for your suggestion ... but the veto extension point works and is really simple to set up.
Lars
you are welcome.
I had written that reply before I saw Dmitry's message.
ah well, 2 answers are better than no answer ;)
Someone else might need to tweak rename. That reply could give them some ideas.