Repository navigation
feat(plugins): Rust SDK 支持构建提供者(litheBuild 0/1),并按桌面端现状更正宿主支持说明 - #117
Merged
Merged
Conversation
Rust SDK 新增 build_model、build_dependencies、build_execute、build_test、 build_discover_tests、build_run_entrypoints、build_prepare_run、 build_prepare_debug 注册方法和 BuildContext,对齐 Node.js SDK 的 build.*: 协商 litheBuild(只在有处理函数时应答 ≤1 的最新版本),每个请求在自己的 线程里运行,检查 operationID、发送有界的 lithe/build/progress,给结果文档 补 format/version 并检查结果形状,映射 PluginError、取消和 panic。 文档同步:Rust SDK README 新增“Build providers”一节;契约 README、插件总览、 原生构建指南、能力与版本、构建提供者参考写明 main 上的 Rust SDK 源码已支持、 随下一次 Rust SDK 发布提供;Node.js SDK README 按桌面端 Declared() 更正 桌面端声明的能力。
桌面端自 Lithe-IDEA #1837 起在构建窗口和标题栏呈现构建提供者的调试准备, #2175 起呈现语言服务器的代码操作、签名帮助和内嵌提示,几页文档仍写尚未呈现。 同时更正 buildProviders 的版本(0 和 1)、构建提供者的运行准备与测试已呈现, 并在调试适配器的桌面端说明里补上 tcpAnnounced。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
类型
feat:Rust SDK 新增构建提供者接口(
litheBuild0 和 1),外加文档更正。契约、能力版本、宿主方法、通知、清单字段和plugin-rpc协议都不变,所以不改协议更新记录;Node.js、Java、Go SDK 的代码也没改。SDK 版本号(0.4.0)不在这个 PR 里升,发布时再定。改动
Rust SDK:构建提供者(
shared/plugins/sdk/rust/plugin-sdk)接口对齐 Node.js SDK 的
backend.build.*。src/backend.rs):build_model、build_dependencies、build_execute、build_test、build_discover_tests、build_run_entrypoints、build_prepare_run、build_prepare_debug,各自对应一个lithe/build/*请求,处理函数签名是Fn(Value, &BuildContext) -> Result<Value, FunctionError>。initialize里提供了experimental.litheBuild时,SDK 才应答{version},取宿主提供的、不超过 1 的最新版本。没有协商成功时,所有lithe/build/*请求都回-32601。只协商到 0 时,runEntrypoints(版本 1 才有)照样回-32601。没注册的请求也回-32601。协商结果可以用BackendHandle::build_version()和Initialize::build_version()读到。execute、test、prepareRun、prepareDebug要求参数是对象,并带有线路上的operationID,否则回-32602。BuildContext(新文件src/build.rs):method()、operation_id()、cancellation()、check_cancelled()。diagnostics()、suppress_success_diagnostics()。progress(message, percentage)和output(text)。host()、backend()。lithe/build/progress,并自动带上operationID。message截到 4 KiB,percentage最大 100。output按 64 KiB 分块,只在字符边界上切。format和version: 0。处理函数写了不一样的值时,按内部错误失败。execute和test要求exitCode是 int32、output是字符串。prepareRun要求executable.kind只能是toolchain或command,arguments是字符串数组,environment的值都是字符串。prepareDebug只能有program、arguments、workingDirectory、environment四个字段。PluginError映射为-32000,带data.code,并在诊断里记下插件错误码。-32800。shutdown会取消还在跑的构建请求。-32603,只上报固定的internal_error类别。operationFinished或operationFailed诊断。src/protocol.rs):BUILD_VERSION = 1、各个lithe/build/*方法名,以及三个上限(结果 32 MiB、消息 4 KiB、输出 64 KiB)。src/lib.rs):导出BuildContext,并在 crate 文档的协议列表里加上litheBuild。测试
src/build.rs新增 4 个单元测试:文档的format/version、任务结果、运行计划与调试目标的形状、哪些请求能上报进度。tests/build.rs新增 11 个集成测试,走 SDK 真实的帧传输:runEntrypoints;没有处理函数或宿主没提供时,不协商;没注册的请求不路由。operationID的检查。PluginError带上错误码。-32800,之后不再上报;shutdown取消正在跑的请求。文档
buildSystems[].provider、invocation、languageServer.launch和process.build权限)、Rust 示例、API 表、语义说明。lithe/build/progress通知,不发lithe/build/*请求)同步更新。main上的 Rust SDK 已支持构建提供者:serde、serde_json、base64。PlanBuildDebug/DecodeBuildDebug,再用这个运行指定的本插件适配器启动。以下几页原先写的是尚未呈现,已更正:buildProviders的版本:构建提供者参考写的是“版本都是 0”,Node.js 和 Java SDK README 写的是“all version 0”,都改成0和1。Node.js SDK README 还补上了桌面端声明的vcsProviders。tcpAnnounced。pluginhost.go里Declared()上方的注释也还写着调试准备尚未呈现,会在 Lithe-IDEA 另开 PR 改掉。验证
cargo +1.87 test --locked --manifest-path shared/plugins/sdk/rust/Cargo.toml:通过(新增 4 个单元测试和 11 个集成测试,已有测试不变)。cargo fmt --manifest-path shared/plugins/sdk/rust/Cargo.toml --all -- --check:通过。cargo clippy --locked --manifest-path shared/plugins/sdk/rust/Cargo.toml --all-targets -- -D warnings:通过。node shared/plugins/scripts/verify-docs.mjs:通过。node shared/plugins/scripts/sdk-e2e.mjs:通过(Node.js、Java、Rust、Go 和 build 共 12 个端到端测试)。没有做的
lithe/build/configuration、editConfiguration)提供类型化处理函数,和 Node.js、Java SDK 一样。