Skip to content

Commit 4f0291c

Browse files
committed
feat(plugin-editor): add navigation semantic action icons to editor actions contract
1 parent d445926 commit 4f0291c

5 files changed

Lines changed: 101 additions & 4 deletions

File tree

‎rust/crates/plugin-editor/src/actions.rs‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,56 @@ mod tests {
646646
assert!(unknown.validate().is_err());
647647
}
648648

649+
#[test]
650+
fn host_options_support_all_desktop_action_icons_within_limit() {
651+
let desktop_icons = vec![
652+
"run".to_string(),
653+
"run-all".to_string(),
654+
"debug".to_string(),
655+
"test".to_string(),
656+
"test-passed".to_string(),
657+
"test-failed".to_string(),
658+
"test-skipped".to_string(),
659+
"navigate-super".to_string(),
660+
"navigate-implementations".to_string(),
661+
"navigate-implemented".to_string(),
662+
"navigate-implementing".to_string(),
663+
"navigate-overridden".to_string(),
664+
"navigate-overriding".to_string(),
665+
];
666+
let options = EditorHostOptions {
667+
action_icons: desktop_icons.clone(),
668+
action_source_bytes: MAX_SOURCE_BYTES,
669+
provider_types: vec![],
670+
};
671+
options.validate().unwrap();
672+
let mut reported = json!({"services":{"editor":{"methods":[]}},"limits":{}});
673+
let granted = BTreeSet::from([REGISTER_ACTIONS.to_string()]);
674+
options.report(&mut reported, &granted);
675+
assert_eq!(
676+
reported["services"]["editor"]["options"]["actionIcons"],
677+
json!(desktop_icons)
678+
);
679+
let decoded = decode_command(json!({
680+
"version": 0,
681+
"kind": "actions",
682+
"icons": desktop_icons,
683+
"sourceBytes": MAX_SOURCE_BYTES,
684+
"text": "interface S {}\n",
685+
"value": {
686+
"actions": [{
687+
"id": "nav",
688+
"range": {"start": {"line": 1, "column": 1}, "end": {"line": 1, "column": 10}},
689+
"title": "Go to implementations",
690+
"icon": "navigate-implemented",
691+
"invoke": {"functionID": "nav.invoke"}
692+
}]
693+
}
694+
}))
695+
.unwrap();
696+
assert_eq!(decoded["actions"][0]["icon"], "navigate-implemented");
697+
}
698+
649699
/// The shared contract fixture: what a host that declared these icons
650700
/// accepts, normalizes or rejects whole.
651701
#[test]

‎shared/plugins/contract/v1/README.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5046,9 +5046,18 @@ workspace context:
50465046
with the same rules and IDs unique within the action, offered in the action's
50475047
menu after the action itself (for example Debug or Test beside Run).
50485048
- The Lithe desktop host draws `run`, `run-all`, `debug`, `test`, `test-passed`,
5049-
`test-failed`, `test-skipped`, `navigate-super` and `navigate-implementations`.
5049+
`test-failed`, `test-skipped`, `navigate-super`, `navigate-implementations`,
5050+
`navigate-implemented`, `navigate-implementing`, `navigate-overridden`, and
5051+
`navigate-overriding`.
50505052
An icon names a picture, not an operation: a test icon does not make the
50515053
action a test, and the host never starts anything because of an icon.
5054+
For gutter navigation, `navigate-implemented` / `navigate-implementing` depict
5055+
interface or contract implementations (downward to implementations, upward to
5056+
implemented contracts), and `navigate-overridden` / `navigate-overriding` depict
5057+
inheritance overrides (downward to overrides, upward to super declarations).
5058+
Plugins should inspect `services.editor.options.actionIcons` returned by
5059+
`lithe/host/getCapabilities` and fall back to `navigate-implementations` or
5060+
`navigate-super` when running on an older host that omits the finer tokens.
50525061
- Each invocation target is a currently registered function of the same plugin;
50535062
`params` is a plugin-private JSON object. The host stores it behind an opaque
50545063
per-batch action key, never accepts invocation payloads from the web editor, and

‎shared/plugins/contract/v1/fixtures/editor/editor-actions.json‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22
"schemaVersion": 1,
33
"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.",
44
"host": {
5-
"actionIcons": ["run", "run-all", "debug", "test", "test-passed", "test-failed", "test-skipped", "navigate-super", "navigate-implementations"],
5+
"actionIcons": [
6+
"run",
7+
"run-all",
8+
"debug",
9+
"test",
10+
"test-passed",
11+
"test-failed",
12+
"test-skipped",
13+
"navigate-super",
14+
"navigate-implementations",
15+
"navigate-implemented",
16+
"navigate-implementing",
17+
"navigate-overridden",
18+
"navigate-overriding"
19+
],
620
"actionSourceBytes": 1048576
721
},
822
"cases": [
@@ -58,6 +72,28 @@
5872
]
5973
}
6074
},
75+
{
76+
"name": "navigation markers distinguish interface implementations and inheritance overrides",
77+
"kind": "actions",
78+
"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",
79+
"value": {
80+
"actions": [
81+
{ "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" } } },
82+
{ "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" } } },
83+
{ "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" } } },
84+
{ "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" } } }
85+
]
86+
},
87+
"expected": {
88+
"status": "accepted",
89+
"value": [
90+
{ "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" } } },
91+
{ "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" } } },
92+
{ "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" } } },
93+
{ "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" } } }
94+
]
95+
}
96+
},
6197
{
6298
"name": "an icon the host did not declare",
6399
"kind": "actions",

‎shared/plugins/reference/domains/editor.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
| 文件 | 内容 |
8181
| --- | --- |
8282
| [`editor/editor-actions.plugin.json`](../../contract/v1/fixtures/editor/editor-actions.plugin.json) | `backend` 加 `editor.actions`、`documents.read`:`onWorkspaceOpen` 启动后注册编辑器动作 |
83-
| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | `plugins.editorActions.decode` 的 8 个 Core 用例:宿主声明的图标和源码上限、`alternatives`、点击结果 `reveal`,以及整个结果被拒绝的情形 |
83+
| [`editor/editor-actions.json`](../../contract/v1/fixtures/editor/editor-actions.json) | `plugins.editorActions.decode` 的 9 个 Core 用例:宿主声明的图标(含接口实现/继承覆写导航图标)和源码上限、`alternatives`、点击结果 `reveal`,以及整个结果被拒绝的情形 |
8484
| [`editor/editor-providers.plugin.json`](../../contract/v1/fixtures/editor/editor-providers.plugin.json) | `backend` 加 `editor.providers`、`documents.read`:`onWorkspaceOpen` 启动后注册编辑器语言功能 Provider |
8585
| [`editor/editor-providers.json`](../../contract/v1/fixtures/editor/editor-providers.json) | Core 注册、结果与合并用例:8 个注册用例、14 个结果用例,以及颜色来源排序、裁切和重复来源 ID 校验 |
8686
| [`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
170170
| File | Content |
171171
| --- | --- |
172172
| [`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` |
173-
| [`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 |
173+
| [`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 |
174174
| [`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` |
175175
| [`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 |
176176
| [`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 |

‎shared/plugins/reference/protocol-changelog.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
## 待合入
1616

17+
- [#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 版本。
18+
1719
- [#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:<hash>`)的 `build.run-type` 生成层配置,与手动创建的同类型配置共用分组、图标、编辑器表单和 `build.runConfigurationPlan` 启动计划;`runConfig.editorForm` 和 `runConfig.saveConfiguration` 支持直接读取并覆盖生成层的 `build.run-type` 配置,且在层合并时整体替换 `extensions.build` 以免被清空的可选字段回渗。没有新增能力版本、宿主方法、通知或 SDK 版本。
1820

1921
- [#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 验证进度取消、结束与订阅释放。没有新增方法、通知、权限、错误码或协议版本。

0 commit comments

Comments
 (0)