mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 02:07:50 +08:00
Merge pull request #236 from Javaru/patch-1
Update VFS changes section due to deprecation
This commit is contained in:
commit
a805128ed5
@ -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?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user