Merge pull request #236 from Javaru/patch-1

Update VFS changes section due to deprecation
This commit is contained in:
Dmitry Jemerov 2019-12-10 11:40:18 +01:00 committed by GitHub
commit a805128ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,21 @@ If you do need to create a file through VFS, you can use the `VirtualFile.create
## How do I get notified when VFS changes?
The `VirtualFileManager.addVirtualFileListener()` method allows you to receive notifications about all changes in the VFS.
Implement the [`BulkFileListener`](upsource:///platform/core-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java) interface and subscribe to the [message bus](/reference_guide/messaging_infrastructure.md) topic `VirtualFileManager.VFS_CHANGES`. For example:
```java
project.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
// handle the events
}
});
```
See [Message Infrastructure](/reference_guide/messaging_infrastructure.md) and [Plugin Listeners](/basics/plugin_structure/plugin_listeners.md) for more details.
For a non-blocking alternative, starting with version 2019.3 of the platform, see [`AsyncFileListener`](upsource:///platform/core-api/src/com/intellij/openapi/vfs/AsyncFileListener.java)
Plugins targeting versions 2017.2 or older of the platform can use the now deprecated ~`VirtualFileManager.addVirtualFileListener()`~ method which allows you to receive notifications about all changes in the VFS.
## Are there any utilities for analyzing and manipulating virtual files?