美文网首页
(十九)IntelliJ 插件开发—— Virtual File

(十九)IntelliJ 插件开发—— Virtual File

作者: 秋水畏寒 | 来源:发表于2020-03-07 14:08 被阅读0次

官方文档

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接口并且监听topicVirtualFileManager.VFS_CHANGES的消息
  • 2019.02及之后的版本可以使用AsyncFileListener

相关文章

网友评论

      本文标题:(十九)IntelliJ 插件开发—— Virtual File

      本文链接:https://www.haomeiwen.com/subject/aixzrhtx.html