Best way for listening files modification/creation

Hi, I need to listen when any xml file is modified or when a new xml file is created.
What is the best way (safer and more efficient) of doing this?

VirtualFileSystem.addVirtualFileListener(VirtualFileListener) ?

Thanks !!
Enrique.

0
3 comments

This depends on the specific task you want to accomplish. VirtualFileListener is one way to solve this, but for files changed inside IntelliJ IDEA, it will only trigger when the file is saved. This may or may not be what you want.

0
Avatar
Permanently deleted user

Thanks Dimitry, I think that's ok for me. But can you tell me what are the other ways for listening file changes?

0

For example you can add a PSI listener via PsiManager.addPsiTreeChangeListener(). Or you can avoid listening to changes yourself and write an index instead: http://confluence.jetbrains.net/display/IDEADEV/Indexing+and+PSI+Stubs+in+IntelliJ+IDEA

0

Please sign in to leave a comment.