PsiTreeChangeListener get file rename event

Hello, community!

Sorry for dummy question, but I'm very confused.
I implemented PsiTreeChangeListener and I'm trying to detect all modifications of files with some extension, like *.java under project source folders.
I want to add path to these files to the some file, and reflect all changes in project structure, concerned with these files.

For the most part of operations with files, like addition or moving, it works perfect.

But for rename operation, I can't obtain previous file name.

I have some test code like this, where event is PsiTreeChangeEvent;

System.out.println(String.valueOf(event.getOldChild()) + " | " + String.valueOf(event.getChild()) + " | " + String.valueOf(event.getNewChild()));
System.out.println(String.valueOf(event.getOldParent()) + " | " + String.valueOf(event.getParent()) + " | " + String.valueOf(event.getNewParent()));

And for rename operation when I'm actually renamed s123.aaa to s1234.aaa. it's output is:

XmlFile:s1234.aaa | null | XmlFile:s1234.aaa
null | PsiDirectory:/..../IdeaProjects/untitled/src/test1 | null


By the way, maybe I can bind file to xml-tag directly?
for each of *.aaa files I'm trying to have xml tag like

<aaa_file path="actual_file_path" />



I'm looked at PsiReference, but didn't understand is it real, to use them. And how.

2 comments

It looks like beforePropertyChange works!

It works with getOldValue() getPropertyName() getNewValue() and produces such result:

s123456789.aaa | fileName | s.aaa

I think, question is not actual now, but if there was a much better way to track project structure modification, I'll gladly read it.

0

Seagull wrote:

It looks like beforePropertyChange works!

It works with getOldValue() getPropertyName() getNewValue() and produces such result:

s123456789.aaa | fileName | s.aaa

I think, question is not actual now, but if there was a much better way to track project structure modification, I'll gladly read it.


  I'll gladly read it too

0

Please sign in to leave a comment.