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.
Please sign in to leave a comment.
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.
Thanks Dimitry, I think that's ok for me. But can you tell me what are the other ways for listening file changes?
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