Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7198,13 +7198,12 @@ section titles translated when the state is. Catalog contributor sections keep
the manifest headings.

`plugins.settings.navigation` accepts at most 576 `items` (512 contributed pages plus 64 host entries), up to three levels
deep, with stable `id`, `title`, nullable `parent`, `group`, `expanded`, optional `keywords` and optional `limit`
(1–512), plus `query` (at most 1024 bytes). It returns `rows` containing id/title/group/expanded/level, `matched`
(the row itself matches the query) and `path` (ancestor titles, root first). Outside search, an item with `limit`
shows that many children followed by one overflow row `{id,title,level,path,overflow}` that carries the item's own
ID and the total child count, so the host can open the item's directory page. Search retains ancestors, shows every
descendant of a matched item and ignores `limit`; ordering follows input. Duplicate IDs, a parent chain that is
missing, cyclic or deeper than three levels, a zero limit and excessive input are rejected.
deep, with stable `id`, `title`, nullable `parent`, `group`, `expanded` and optional `keywords`, plus `query` (at
most 1024 bytes). It returns `rows` containing id/title/group/expanded/level, `matched` (the row itself matches the
query) and `path` (ancestor titles, root first). Outside search, a collapsed group hides its children. Search
retains ancestors and shows every descendant of a matched item; ordering follows input. Unknown fields are an
`invalid_request`. Duplicate IDs, a parent chain that is missing, cyclic or deeper than three levels and excessive
input are rejected.

`plugins.settings.delivery` accepts `scope` (global/project), native equality
facts `samePreferences`, `sameWorkspace`, `sameVersion`, current `enabled`, and
Expand Down
36 changes: 20 additions & 16 deletions rust/crates/core/src/tests/plugin_settings_documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ fn build_tree(languages: usize) -> Vec<Value> {
let mut items = vec![
json!({"id":"build","title":"Build","parent":null,"group":true,"expanded":true}),
json!({"id":"toolchains","title":"Toolchains","parent":"build","group":false,"expanded":false}),
json!({"id":"kind:language","title":"Languages","parent":"build","group":true,"expanded":true,"limit":6}),
json!({"id":"kind:language","title":"Languages","parent":"build","group":true,"expanded":true}),
];
for index in 0..languages {
items.push(json!({"id":format!("language:{index}"),"title":format!("Language {index}"),"parent":"kind:language","group":false,"expanded":false,"keywords":if index == 9 {"cargo"} else {""}}));
Expand All @@ -397,19 +397,16 @@ fn navigation_rows(items: Vec<Value>, query: &str) -> Vec<Value> {
response["data"]["rows"].as_array().unwrap().clone()
}

/// A kind fold under a group shows its first `limit` pages and one overflow row
/// that counts every page; search ignores the limit and lists hits with their path.
/// An expanded kind under a group lists every page at the third level with its
/// path; search lists hits with their path.
#[test]
fn settings_navigation_folds_a_third_level_behind_an_overflow_row() {
fn settings_navigation_lists_a_third_level_and_search_hits_with_their_path() {
let rows = navigation_rows(build_tree(12), "");
assert_eq!(rows.len(), 3 + 6 + 1);
assert_eq!(rows.len(), 3 + 12);
assert_eq!(rows[2]["level"], 1);
assert_eq!(rows[3]["level"], 2);
let overflow = &rows[9];
assert_eq!(overflow["id"], "kind:language");
assert_eq!(overflow["overflow"], 12);
assert_eq!(overflow["level"], 2);
assert_eq!(overflow["path"], json!(["Build", "Languages"]));
assert_eq!(rows[14]["id"], "language:11");
assert_eq!(rows[14]["path"], json!(["Build", "Languages"]));
assert!(rows.iter().all(|row| row["matched"] == false));

let rows = navigation_rows(build_tree(12), "CARGO");
Expand All @@ -419,28 +416,35 @@ fn settings_navigation_folds_a_third_level_behind_an_overflow_row() {
assert_eq!(rows[2]["path"], json!(["Build", "Languages"]));
assert_eq!(rows[0]["matched"], false);

// A matched fold shows every page below it, still without the limit.
// A matched kind shows every page below it.
let rows = navigation_rows(build_tree(12), "languages");
assert_eq!(rows.len(), 2 + 12);
assert!(rows.iter().all(|row| row.get("overflow").is_none()));
}

#[test]
fn settings_navigation_rejects_a_fourth_level_cycles_and_empty_limits() {
fn settings_navigation_rejects_a_fourth_level_cycles_and_unknown_fields() {
let mut deep = build_tree(1);
deep.push(json!({"id":"too-deep","title":"Deep","parent":"language:0","group":false,"expanded":false}));
let mut cycle = build_tree(0);
cycle.push(json!({"id":"a","title":"A","parent":"b","group":false,"expanded":false}));
cycle.push(json!({"id":"b","title":"B","parent":"a","group":false,"expanded":false}));
let mut empty = build_tree(1);
empty[2]["limit"] = json!(0);
for items in [deep, cycle, empty] {
for items in [deep, cycle] {
let response = execute(
"plugins.settings.navigation",
json!({"items":items,"query":""}),
);
assert_eq!(response["data"]["status"], "rejected", "{response}");
}

// Fields the projection does not read, such as the removed `limit`, are an
// invalid request rather than silently ignored.
let mut unknown = build_tree(1);
unknown[2]["limit"] = json!(6);
let response = execute(
"plugins.settings.navigation",
json!({"items":unknown,"query":""}),
);
assert_eq!(response["error"]["code"], "invalid_request", "{response}");
}

fn contract_settings_file(name: &str) -> String {
Expand Down
5 changes: 2 additions & 3 deletions rust/crates/core/src/tests/toolchain_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ fn tool_definitions_declare_settings_category_and_audience() {
tagged["audience"] = json!("plugin");
let mut plugin = manifest("dev.lithe.fixture.compiler", tagged);
// The fields are toolDefinitions 1, so a host that supports only 0 never installs it.
let rejected = validate_manifest_value(plugin.clone())
.err()
.expect("version 0 refuses settings categories");
let rejected =
validate_manifest_value(plugin.clone()).expect_err("version 0 refuses settings categories");
assert_eq!(rejected.field.as_deref(), Some("requires.toolDefinitions"));
plugin["requires"]["toolDefinitions"] = json!(1);
assert!(validate_manifest_value(plugin.clone()).is_ok());
Expand Down
24 changes: 3 additions & 21 deletions rust/crates/plugin-manifest/src/settings_surfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn settings_catalog_command(payload: Value) -> Result<Value, CoreError> {
}

/// Native static page labels and stable identifiers. Hierarchy is supplied once;
/// search, expansion, folding and ancestor retention are shared projection rules.
/// search, expansion and ancestor retention are shared projection rules.
#[derive(Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct NavigationItem {
Expand All @@ -115,10 +115,6 @@ struct NavigationItem {
expanded: bool,
#[serde(default)]
keywords: String,
/// Shows at most this many children outside search; the rest fold into one
/// overflow row that opens the group's own directory page.
#[serde(default)]
limit: Option<usize>,
}

#[derive(Deserialize)]
Expand All @@ -128,7 +124,7 @@ struct NavigationRequest {
query: String,
}

/// The deepest level a row may sit at: group, kind fold, page.
/// The deepest level a row may sit at: group, kind, page.
const MAX_LEVEL: usize = 2;

struct Navigation<'a> {
Expand Down Expand Up @@ -171,22 +167,11 @@ impl<'a> Navigation<'a> {
if item.group && !item.expanded && !searching {
return;
}
let children = self.children(&item.id);
let limit = match item.limit {
Some(limit) if !searching => limit,
_ => children.len(),
};
let mut below = path.to_vec();
below.push(&item.title);
for child in children.iter().take(limit) {
for child in self.children(&item.id) {
self.emit(child, level + 1, &below, shown || own);
}
if children.len() > limit {
self.rows.push(json!({
"id":item.id,"title":item.title,"group":false,"expanded":false,
"level":level + 1,"matched":false,"path":below,"overflow":children.len(),
}));
}
}
}

Expand All @@ -206,9 +191,6 @@ pub fn settings_navigation_command(payload: Value) -> Result<Value, CoreError> {
|| item.id.len() > 256
|| item.title.len() > 1024
|| item.keywords.len() > 16384
|| item
.limit
.is_some_and(|limit| limit == 0 || limit > MAX_PAGES)
|| !ids.insert(&item.id)
{
return Err(rejected("items"));
Expand Down
5 changes: 4 additions & 1 deletion rust/crates/toolchain/src/settings_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ mod tests {
.iter()
.map(|issue| issue["group"].as_str().unwrap_or_default())
.collect();
assert_eq!(groups, ["category:runtime", "audience:plugin", "category:build"]);
assert_eq!(
groups,
["category:runtime", "audience:plugin", "category:build"]
);
let flat = view(sample(), json!({"groupBy":"none"}));
assert!(flat["issues"][0].get("group").is_none());
}
Expand Down
3 changes: 2 additions & 1 deletion shared/plugins/reference/protocol-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## 待合入

- `toolDefinitions` 1 内的补充(API-23、API-19):`toolchains.settingsView` 的 `issues` 每项改为 `{index,status,group?}`:查询分组时 `group` 是工具所在分组的键,宿主从问题列表打开这个工具时可以一并展开它的分组,不必自己拼分组键;契约 README 同时写明 `issues` 一直不受查询影响、先错误后警告并各按名称排序。没有新增版本号、宿主方法、通知或 SDK 版本。实现见 [#102](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/102)([@xiaoyumuxi](https://github.com/xiaoyumuxi))。
目前没有。

## 按协议查首次出现

Expand Down Expand Up @@ -148,6 +148,7 @@

| PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 |
| --- | --- | --- | --- | --- |
| [#102](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/102) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-23、API-19 | `toolDefinitions` 1 内的补充 | `toolchains.settingsView` 的 `issues` 每项改为 `{index,status,group?}`:查询分组时 `group` 是工具所在分组的键,宿主从问题列表打开这个工具时可以一并展开它的分组,不必自己拼分组键;契约 README 同时写明 `issues` 一直不受查询影响、先错误后警告并各按名称排序。没有新增版本号、宿主方法、通知或 SDK 版本。 |
| [#99](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/99) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-23、API-19 | **`toolDefinitions` 1** | 工具定义新增只影响显示位置的 `category`(`runtime`、`build`、`package`、`debug`、`lint`、`other`,默认 `other`)和 `audience`(`user` 默认,`plugin` 表示插件自用的运行时);用到任一字段的插件声明 `toolDefinitions: 1`,只支持 0 的宿主不会安装,其他插件继续写 0。新增 Core 命令 `toolchains.settingsView`:按宿主已有的解析原因、固定和未应用状态给设置页工具列表分类(`error`、`warning`、`ok`)、筛选、分组、折叠和计数,最多 20,000 个工具。`plugins.settings.navigation` 支持三级、每项可选 `limit`(超出的子项折叠成一行“全部 N 个”)以及每行的 `matched` 与 `path`。清单 schema 的 `requires.buildProviders` 补上 #89 已支持的版本 1。没有新增宿主方法、通知或 SDK 版本。宿主须先声明 `toolDefinitions` 1,插件才可要求它。 |
| [#97](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/97) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-29 | **`beforeLaunchTasks` 0** | 运行配置“启动前”的插件任务(对标 IntelliJ IDEA 的“添加新任务”,[1lck/Lithe-IDEA#2100](https://github.com/1lck/Lithe-IDEA/issues/2100)):构建系统新增 `beforeLaunchTasks`(最多 16 个),声明方式和 `runConfigurationTypes` 相同(`id`、`displayName`、可选 `description`、`icon`、最多 16 个 `fields` 和 `arguments` 模板),但任务总是运行到结束,不能写 `execution`,`arguments` 不能用 `${userArguments}`;任务 ID 与类型 ID 各自唯一。运行配置的 `beforeLaunch` 步骤除 `{configuration}` 外新增 `{task: {pluginID, buildSystemID, type, values}}`,任务在拥有这个步骤列表的配置的工作目录里运行,不带程序参数和环境变量;步骤对象不允许出现别的键。Core 新增命令 `runConfig.checkBeforeLaunchTask`(校验“添加新任务”小表单的值,返回要放进字段值的步骤)、`runConfig.beforeLaunchField`(给不用 `runConfig.editorForm` 的编辑器,例如构建运行的编辑器,返回已保存配置的 `beforeLaunch` 字段)和 `build.beforeLaunchTaskPlan`(把任务步骤展开成 argv 计划);`runConfig.editorForm` 的 `beforeLaunch` 字段新增 `tasks`(已安装插件声明的任务种类及其表单),字段值里的任务步骤是 `{task, name, summary, values}`,插件已卸载的是 `{task, name, summary, missing: true}`;`runConfig.beforeLaunch`、`runConfig.updateOptions`、`runConfig.saveEditorChanges` 新增请求字段 `runTypePlugins`,`runConfig.beforeLaunch` 的任务步骤返回 `{task, name, summary, workingDirectory}`,拒绝码新增 `taskNotDeclared` 和 `invalidTaskValues`(带 `task`),确认指纹也覆盖任务及其值和工作目录。`runConfigurationTypes` 的必填 `arguments` 字段留空现在会被拒绝(以前没有执行 `required`)。语言文件新增 `beforeLaunchTasks.<构建系统 ID>.<任务 ID>`;保存的值不合法时是 `plugin.build.invalidBeforeLaunchTask`(字段 `values.<id>`)。新增 fixture `before-launch-tasks/`。用到它的插件声明 `beforeLaunchTasks: 0`,不认识它的宿主不会安装。没有新增宿主方法或通知。 |
| [#96](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/96) | [@lithe-support[bot]](https://github.com/apps/lithe-support) | API-23 | **`managedRuntimes` 0** | 受管运行时:新增固定 HTTPS 归档与 SHA-256、平台选择、与插件版本无关的缓存身份,以及插件后端对外部/暂存依赖的资格检查契约。新增权限 `runtimes.install`、审查程序 `managedRuntime`、Core 命令 `plugins.managedRuntimes.plan` 与 `plugins.managedRuntimes.decodeResolution`;正常语言服务器启动可接收只读 `runtimes` 映射。原生 `lsp.startServer` 新增可选 `functionRelayEnabled`(默认 true),准备会话设为 false 隔离跨插件调用但保留宿主直接调用。无新增宿主 RPC 或 SDK 版本。宿主须先发布对应能力,插件才可要求它。 |
Expand Down
Loading