From 4f0291cff3fa4a70ab5e57887a2842255bf3d6ef Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Tue, 24 Nov 2026 04:56:39 -0800 Subject: [PATCH] feat(plugin-editor): add navigation semantic action icons to editor actions contract --- rust/crates/plugin-editor/src/actions.rs | 50 +++++++++++++++++++ shared/plugins/contract/v1/README.md | 11 +++- .../v1/fixtures/editor/editor-actions.json | 38 +++++++++++++- shared/plugins/reference/domains/editor.md | 4 +- .../plugins/reference/protocol-changelog.md | 2 + 5 files changed, 101 insertions(+), 4 deletions(-) diff --git a/rust/crates/plugin-editor/src/actions.rs b/rust/crates/plugin-editor/src/actions.rs index 239062b9..e39e557b 100644 --- a/rust/crates/plugin-editor/src/actions.rs +++ b/rust/crates/plugin-editor/src/actions.rs @@ -646,6 +646,56 @@ mod tests { assert!(unknown.validate().is_err()); } + #[test] + fn host_options_support_all_desktop_action_icons_within_limit() { + let desktop_icons = vec![ + "run".to_string(), + "run-all".to_string(), + "debug".to_string(), + "test".to_string(), + "test-passed".to_string(), + "test-failed".to_string(), + "test-skipped".to_string(), + "navigate-super".to_string(), + "navigate-implementations".to_string(), + "navigate-implemented".to_string(), + "navigate-implementing".to_string(), + "navigate-overridden".to_string(), + "navigate-overriding".to_string(), + ]; + let options = EditorHostOptions { + action_icons: desktop_icons.clone(), + action_source_bytes: MAX_SOURCE_BYTES, + provider_types: vec![], + }; + options.validate().unwrap(); + let mut reported = json!({"services":{"editor":{"methods":[]}},"limits":{}}); + let granted = BTreeSet::from([REGISTER_ACTIONS.to_string()]); + options.report(&mut reported, &granted); + assert_eq!( + reported["services"]["editor"]["options"]["actionIcons"], + json!(desktop_icons) + ); + let decoded = decode_command(json!({ + "version": 0, + "kind": "actions", + "icons": desktop_icons, + "sourceBytes": MAX_SOURCE_BYTES, + "text": "interface S {}\n", + "value": { + "actions": [{ + "id": "nav", + "range": {"start": {"line": 1, "column": 1}, "end": {"line": 1, "column": 10}}, + "title": "Go to implementations", + "icon": "navigate-implemented", + "invoke": {"functionID": "nav.invoke"} + }] + } + })) + .unwrap(); + assert_eq!(decoded["actions"][0]["icon"], "navigate-implemented"); + } + /// The shared contract fixture: what a host that declared these icons /// accepts, normalizes or rejects whole. #[test] diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index 7f7fa699..e77a1ed0 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -5046,9 +5046,18 @@ workspace context: with the same rules and IDs unique within the action, offered in the action's menu after the action itself (for example Debug or Test beside Run). - The Lithe desktop host draws `run`, `run-all`, `debug`, `test`, `test-passed`, - `test-failed`, `test-skipped`, `navigate-super` and `navigate-implementations`. + `test-failed`, `test-skipped`, `navigate-super`, `navigate-implementations`, + `navigate-implemented`, `navigate-implementing`, `navigate-overridden`, and + `navigate-overriding`. An icon names a picture, not an operation: a test icon does not make the action a test, and the host never starts anything because of an icon. + For gutter navigation, `navigate-implemented` / `navigate-implementing` depict + interface or contract implementations (downward to implementations, upward to + implemented contracts), and `navigate-overridden` / `navigate-overriding` depict + inheritance overrides (downward to overrides, upward to super declarations). + Plugins should inspect `services.editor.options.actionIcons` returned by + `lithe/host/getCapabilities` and fall back to `navigate-implementations` or + `navigate-super` when running on an older host that omits the finer tokens. - Each invocation target is a currently registered function of the same plugin; `params` is a plugin-private JSON object. The host stores it behind an opaque per-batch action key, never accepts invocation payloads from the web editor, and diff --git a/shared/plugins/contract/v1/fixtures/editor/editor-actions.json b/shared/plugins/contract/v1/fixtures/editor/editor-actions.json index 88550cca..d5e4ee15 100644 --- a/shared/plugins/contract/v1/fixtures/editor/editor-actions.json +++ b/shared/plugins/contract/v1/fixtures/editor/editor-actions.json @@ -2,7 +2,21 @@ "schemaVersion": 1, "description": "Editor action validation through `plugins.editorActions.decode`. Every case is sent as the request `{version, kind, icons, sourceBytes, text, value}`: `version` is required and is `0` (Core accepts only `0`, otherwise `Unsupported editor action validation version.`); `icons` and `sourceBytes` are the `host` members below, which the host declared in getCapabilities (`services.editor.options.actionIcons` and `limits.editorActionSourceBytes`); `kind` is `actions` for a collector result (one-based UTF-16 positions in `text`) or `invokeResult` for the result of a clicked action or alternative. Accepted cases list the normalized value; rejected cases reject the whole result.", "host": { - "actionIcons": ["run", "run-all", "debug", "test", "test-passed", "test-failed", "test-skipped", "navigate-super", "navigate-implementations"], + "actionIcons": [ + "run", + "run-all", + "debug", + "test", + "test-passed", + "test-failed", + "test-skipped", + "navigate-super", + "navigate-implementations", + "navigate-implemented", + "navigate-implementing", + "navigate-overridden", + "navigate-overriding" + ], "actionSourceBytes": 1048576 }, "cases": [ @@ -58,6 +72,28 @@ ] } }, + { + "name": "navigation markers distinguish interface implementations and inheritance overrides", + "kind": "actions", + "text": "interface Service { void run(); }\nclass Impl implements Service {\n public void run() {}\n}\nclass Base { void step() {} }\nclass Sub extends Base {\n void step() {}\n}\n", + "value": { + "actions": [ + { "id": "iface-down", "range": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 10 } }, "title": "Go to implementations", "icon": "navigate-implemented", "invoke": { "functionID": "nav.invoke", "params": { "direction": "down", "relation": "interface" } } }, + { "id": "impl-up", "range": { "start": { "line": 3, "column": 1 }, "end": { "line": 3, "column": 2 } }, "title": "Go to interface declaration", "icon": "navigate-implementing", "invoke": { "functionID": "nav.invoke", "params": { "direction": "up", "relation": "interface" } } }, + { "id": "base-down", "range": { "start": { "line": 5, "column": 1 }, "end": { "line": 5, "column": 6 } }, "title": "Go to overriding subclasses", "icon": "navigate-overridden", "invoke": { "functionID": "nav.invoke", "params": { "direction": "down", "relation": "inheritance" } } }, + { "id": "sub-up", "range": { "start": { "line": 7, "column": 1 }, "end": { "line": 7, "column": 2 } }, "title": "Go to super method", "icon": "navigate-overriding", "invoke": { "functionID": "nav.invoke", "params": { "direction": "up", "relation": "inheritance" } } } + ] + }, + "expected": { + "status": "accepted", + "value": [ + { "id": "iface-down", "range": { "start": { "line": 1, "column": 1 }, "end": { "line": 1, "column": 10 } }, "title": "Go to implementations", "icon": "navigate-implemented", "invoke": { "functionID": "nav.invoke", "params": { "direction": "down", "relation": "interface" } } }, + { "id": "impl-up", "range": { "start": { "line": 3, "column": 1 }, "end": { "line": 3, "column": 2 } }, "title": "Go to interface declaration", "icon": "navigate-implementing", "invoke": { "functionID": "nav.invoke", "params": { "direction": "up", "relation": "interface" } } }, + { "id": "base-down", "range": { "start": { "line": 5, "column": 1 }, "end": { "line": 5, "column": 6 } }, "title": "Go to overriding subclasses", "icon": "navigate-overridden", "invoke": { "functionID": "nav.invoke", "params": { "direction": "down", "relation": "inheritance" } } }, + { "id": "sub-up", "range": { "start": { "line": 7, "column": 1 }, "end": { "line": 7, "column": 2 } }, "title": "Go to super method", "icon": "navigate-overriding", "invoke": { "functionID": "nav.invoke", "params": { "direction": "up", "relation": "inheritance" } } } + ] + } + }, { "name": "an icon the host did not declare", "kind": "actions", diff --git a/shared/plugins/reference/domains/editor.md b/shared/plugins/reference/domains/editor.md index e4693513..a4bb30af 100644 --- a/shared/plugins/reference/domains/editor.md +++ b/shared/plugins/reference/domains/editor.md @@ -80,7 +80,7 @@ | 文件 | 内容 | | --- | --- | | [`editor/editor-actions.plugin.json`](../../contract/v1/fixtures/editor/editor-actions.plugin.json) | `backend` 加 `editor.actions`、`documents.read`:`onWorkspaceOpen` 启动后注册编辑器动作 | -| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | `plugins.editorActions.decode` 的 8 个 Core 用例:宿主声明的图标和源码上限、`alternatives`、点击结果 `reveal`,以及整个结果被拒绝的情形 | +| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | `plugins.editorActions.decode` 的 9 个 Core 用例:宿主声明的图标(含接口实现/继承覆写导航图标)和源码上限、`alternatives`、点击结果 `reveal`,以及整个结果被拒绝的情形 | | [`editor/editor-providers.plugin.json`](../../contract/v1/fixtures/editor/editor-providers.plugin.json) | `backend` 加 `editor.providers`、`documents.read`:`onWorkspaceOpen` 启动后注册编辑器语言功能 Provider | | [`editor/editor-providers.json`](../../contract/v1/fixtures/editor/editor-providers.json) | Core 注册、结果与合并用例:8 个注册用例、14 个结果用例,以及颜色来源排序、裁切和重复来源 ID 校验 | | [`backend/command-backend.plugin.json`](../../contract/v1/fixtures/backend/command-backend.plugin.json) | 无工具窗口的 `ui` 命令读取文档并编辑 | @@ -170,7 +170,7 @@ A language server may hand out documents that have no file (such as the decompil | File | Content | | --- | --- | | [`editor/editor-actions.plugin.json`](../../contract/v1/fixtures/editor/editor-actions.plugin.json) | `backend` with `editor.actions` and `documents.read`: registers editor actions after `onWorkspaceOpen` | -| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | 8 Core cases for `plugins.editorActions.decode`: the host-declared icons and source limit, `alternatives`, click-result `reveal`, and results refused whole | +| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | 9 Core cases for `plugins.editorActions.decode`: the host-declared icons (including interface implementation and inheritance override navigation tokens) and source limit, `alternatives`, click-result `reveal`, and results refused whole | | [`editor/editor-providers.plugin.json`](../../contract/v1/fixtures/editor/editor-providers.plugin.json) | `backend` with `editor.providers` and `documents.read`: registers editor language-feature providers after `onWorkspaceOpen` | | [`editor/editor-providers.json`](../../contract/v1/fixtures/editor/editor-providers.json) | Core cases for registrations, results, and merges, including color legend and range validation and stable source priority | | [`backend/command-backend.plugin.json`](../../contract/v1/fixtures/backend/command-backend.plugin.json) | A `ui` command without a tool window that reads and edits documents | diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index f6d1ee25..b267f554 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,6 +14,8 @@ ## 待合入 +- [#198](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/198)(2026-11-24),[@1lck](https://github.com/1lck),`pluginAPIVersion` 0 / `litheFunctions` 0 内补充(API-27):`editor/registerActions` 的 `services.editor.options.actionIcons` 新增四个通用行首导航图标 token:`navigate-implemented`(接口/契约有子实现,向下)、`navigate-implementing`(实现接口/契约,向上)、`navigate-overridden`(父类/方法被覆写,向下)、`navigate-overriding`(覆写父类声明,向上),保留已有 `navigate-super` 与 `navigate-implementations` 向后兼容。`plugins.editorActions.decode` 仍由宿主声明的 `actionIcons` 列表动态校验,插件通过 `getCapabilities` 发现是否支持新 token,在旧宿主上回退到原有图标;契约 README、领域参考与 `fixtures/editor/editor-actions.json` 同步更新。没有新增能力版本、协议版本、宿主方法、通知或 SDK 版本。 + - [#196](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/196)(合入日期待合并时填写),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`runConfigurationTypes` 0 内的补充(API-29):`buildSystems[].run[]` 新增可选字段 `configurationType`(引用同一构建系统的 `runConfigurationTypes[].id`)和 `values`(按字段 ID 填写初始值,字符串与 `arguments` 列表项支持 `${root}`、`${project.*}`、`${target.*}` 模板展开),必须配合 `fromTargets` 使用,与 `source: "provider"`、`debug`、`entrypoints`、`fromTasks`、`arguments`、`extension`、`execution` 互斥;清单继续写 `requires.runConfigurationTypes: 0`(旧宿主 Core 因 `deny_unknown_fields` 会直接以 `plugin.manifest.invalid` 拒绝,不会静默忽略)。`build.decodeModel` 展开模板并在 `model.run[]` 中输出 `provider: "build.run-type"` 与 `runType: {pluginID, buildSystemID, type, values}`;`runConfig.generate` 的 `providerRuns` 快照支持物化为确定性 ID(`generated:run-type:`)的 `build.run-type` 生成层配置,与手动创建的同类型配置共用分组、图标、编辑器表单和 `build.runConfigurationPlan` 启动计划;`runConfig.editorForm` 和 `runConfig.saveConfiguration` 支持直接读取并覆盖生成层的 `build.run-type` 配置,且在层合并时整体替换 `extensions.build` 以免被清空的可选字段回渗。没有新增能力版本、宿主方法、通知或 SDK 版本。 - [#194](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/194)(待合入),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`pluginAPIVersion` 0 / `litheFunctions` 0 内修正(API-03、API-16):`plugins.workflow` 在原生副作用前校验状态项引用的命令属于调用会话清单、Markdown/HTML 资源扩展名及浏览器资源的 `unsaved` 默认值;预览省略 `presentation` 时仍为 `editorAndPreview`,浏览器省略 `unsaved` 时仍为 `requireSaved`。补齐内核命令总表遗漏的 `plugins.workflow`,修正 Rust SDK 测试模块位置,并在四种官方 SDK 验证进度取消、结束与订阅释放。没有新增方法、通知、权限、错误码或协议版本。