包阅导读总结
1.
关键词:JetBrains Platform、Workspace Model、Plugin Developers、Project Models、API
2.
总结:JetBrains Platform 的 Workspace Model 已结束实验阶段,为项目模型内部存储,插件开发者可安全访问和修改,有诸多优势,新 API 已可用,未来将允许开发者定义自身实体,消除写锁等。
3.
主要内容:
– JetBrains Platform
– Workspace Model
– 结束实验阶段,为项目模型内部存储
– 插件开发者可访问和修改
– 有集中式 API、批量更新、协程和持久数据结构
– JPS 项目模型新实现
– 支持旧接口保持兼容
– 鼓励开发者更新到新 API
– Workspace Model 优势
– 持久数据结构,支持多线程
– 单一存储和更新入口
– 提高性能和灵活性
– 进一步发展
– 允许开发者定义自身实体
– 未来消除写锁
– 新代码用新 API,部分子系统迁移
思维导图:
文章地址:https://blog.jetbrains.com/platform/2024/08/workspace-model/
文章来源:blog.jetbrains.com
作者:Alex Plate
发布时间:2024/8/28 7:58
语言:英文
总字数:636字
预计阅读时间:3分钟
评分:84分
标签:工作区模型,JetBrains 平台,插件开发,项目模型,持久化数据结构
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
Workspace Model
The Workspace Model, which serves as the internal storage for project models, has exited its experimental phase. Plugin developers can now safely access and modify the workspace model, benefiting from a centralized API, bulk updates, coroutines, and a persistent data structure.
This update is particularly relevant for developers working on build tool integration plugins, such as Maven, Gradle, BSP, Bazel, and others. Additionally, it will be useful for any plugin developers who interact with the JPS project model, known for classes like Module
, Library
, Facet
, ModuleManager
, IdeModifiableModelsProvider
, and others.
New Implementation of the JPS project model
Some time ago, we announced the reimplementation of project models. The IntelliJ platform still supports old interfaces like Module and ModuleManager to maintain compatibility with existing plugins. However, the new Workspace Model API is now also available for public use. Plugin developers are encouraged to update their code from the old API to the new API. More information on code migration can be found here.
The Workspace Model is designed to store any entities, including those defined by plugins. However, defining custom entities is still an experimental part of the API and will be released later. Currently, working with the Workspace Model is limited to using entities provided by the platform.
Benefits of the Workspace Model
The Workspace Model is designed as a persistent data structure, enabling it to handle various multithreading use cases. A snapshot of the storage is immutable and can be processed without a read lock. Batch operations like replaceBySource
and applyChangesFrom
are designed to support scenarios involving significant updates to the workspace model.
Compared to the previous implementation of the project models, the Workspace Model keeps everything in one storage, there is a single entry point for all updates, and there is no need to create multiple modifiable models as before. Also, as the old project model API now delegates to the Workspace Model, accessing the new API directly may improve the performance, especially for massive operations or big projects.
The flexibility of the Workspace Model allows the entire IntelliJ Platform to change the way we work with the project model. Rather than using specific managers, the subsystem can define extension points that can be contributed by other subsystems. For example, the new WorkspaceFileIndex
operates on entities provided by different parts of the IDE instead of directly using the ModuleManager
.
The event flow allows you to observe all changes occurring within the storage. Every update can be used to incrementally affect subsystems that depend on Workspace Model data. This feature has been utilized to remove some internal implementations of AdditionalLibraryRootsProvider
and DirectoryIndexExcludePolicy
, which were recalculated from scratch on each change of the project models, leading to improved performance of JetBrains IDEs.
Further evolution
The new Workspace model is already used in several places. The Rider IDE was the first client of the Workspace Model, and it still actively uses it. The Maven import was rewritten to the new API, giving a boost in performance. Different parts of GoLand, WebStorm, and the Kotlin plugin also started to use the new approach, gaining different benefits.
The next steps for the Workspace Model will focus on allowing plugin developers to define and use their own entities. This will make it possible to describe the project model of a build tool with specific entities that accurately reflect the structure of the project.
Currently, updates to the Workspace Model occur under a write lock. Future updates will eliminate this requirement, allowing updates to happen without acquiring any locks.
The IntelliJ platform still mostly uses the old API for working with the project models, however, all new code will be written using the new Workspace Model API. The subsystems that will benefit from the performance of the new API will also be migrated.