How to prevent renaming of library functions?
Hi,
I've managed to implement a reference contributor as detailed out under http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/reference_contributor.html. It works well and it also allows to jump to the declaration of library function (which are are attached as a library under "External Libraries".
However, even if it's great that I can search for usage and jump to declarations of library method, I'd like to the UI to NOT show the rename dialog for library methods. How can I prevent this if a function is detected as being part of a library (which I tend to check via something like:
MyUtils.isLibraryFile(psiElement.getContainingFile())
Best.
Holger
Please sign in to leave a comment.
See extension point com.intellij.vetoRenameCondition, you must provide implementation of Condition<PsiElement> returning true if renaming should be forbidden.
This was much simpler than I ever imagined. Works like charm, here's the code in case anyone needs an example: https://github.com/holgerbrandl/r4intellij/blob/master/src/com/r4intellij/psi/references/RenamingVetoCondition.java
So thanks a lot for the nice and efficient help.
Cheers,
Holger