Listen for file changes in just a single project?

When I have code like:

MessageBusConnection connection = project.getMessageBus().connect();

connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event: events) {
System.out.println("event = " + event);
}
}
});

I seem to be notified of all virtual filesystem events, not just the one specific for the project I specified.

Is there a way to subscribe to events only for files in a specific project?

1
1 comment
Official comment

You can check com.intellij.openapi.roots.FileIndex#isInContent for ProjectFileIndex. Please see http://www.jetbrains.org/intellij/sdk/docs/basics/virtual_file_system.html#virtual-file-system-events

Please sign in to leave a comment.