官方文档
https://www.jetbrains.org/intellij/sdk/docs/basics/virtual_file_system.htmll)
Github
https://github.com/kungyutucheng/my_gradle_plugin
运行环境
macOS 10.14.5
IntelliJ idea 2019.2.4
定义
虚拟文件系统主要为以下几个意图服务:
- 无视文件实际位置,提供一个统一的api
Providing a universal API for working with files regardless of their actual location (on disk, in archive, on a HTTP server etc.)
- 追踪文件修改行为,并在发现修改时提供新旧版本的文件内容
Tracking file modifications and providing both old and new versions of the file content when a modification is detected.
- 为VFS中的文件关联额外的持久数据提供可能
Providing a possibility to associate additional persistent data with a file in the VFS.
为了提供后面俩个特性,VFS会保存一份持久化的快照文件内容,这份快照内容是application
级别的,因此多个project
共用同一份文件快照,并且,当硬盘上的文件内容更新时,快照内容也会异步更新
Virtual file system events
VFS的变更事件可以通过以下俩种方式监听:
- 通过实现
BulkFileListener
接口并且监听topic
为VirtualFileManager.VFS_CHANGES
的消息 - 2019.02及之后的版本可以使用
AsyncFileListener
网友评论