Change contents of file when a directory is renamed
Answered
Suppose we have a directory named "dir" in a project, and a language file in the same project (but not necessarily under dir), that has the following text:
dir/some_other_text
This line directly references something in that directory. Therefore, if we change dir's name to something else like "bir" the text of the file should become
bir/some_other_text
How can I implement a feature in my plugin that applies that change to the file (or files) when the relevant directory is renamed?
Please sign in to leave a comment.
Ideally you would use PsiReference to resolve to that directory, which would also then handle renaming http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi_references.html
see com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet
First, its good to know that references are the right way when I need to reference directories.
However, although the above strategy would work just fine, I have an intermediate PSI object that:
The issue I encountered is that when I rename the directory, the reference from the intermediate object to the directory is not created, and thus that intermediate object does not process the refactoring and does not pass the action to the files which reference it.
Do I have to create a reference directly from the file to the directories, or is it somehow possible to use references of references?
Please consider using com.intellij.pom.PomRenameableTarget for your intermediate object.