Skip to content

feat(lsp-policy): 问题工具窗口的树行、折叠与选中交给 Core - #82

Merged
xiaoyumuxi merged 2 commits into
mainfrom
feat/problems-tree
Nov 17, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
feat/problems-tree

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue

类型

feat:lsp.problems.query 增加树状态入参,返回可见行和选中行;文件分组带 name、folder

改动

桌面端的问题(Problems)工具窗口改成 IDEA 那样的树:文件或严重程度节点可以展开收起,下面是问题行。原来宿主把分组结果平铺成行,展开状态和选中要移到哪一行都得自己算。本 PR 把这些规则放进 Core,宿主只保留折叠键、选中键和绘制,和 lsp.references.query(#80)同一种写法。

新增字段
请求 collapsed?:[groupKey](关着的节点键,未知键忽略)、selected?(选中行键)
返回 rows:[{key,kind,depth,expanded?,group?,shows}]、selected?、selectedRow?;groups[] 的文件分组多 name、folder

原有的 groups、files、visibleCounts、totalCounts 不变。

规则(rust/crates/lsp-policy/src/problems.rs):

  • 行键:文件节点 file:<fileKey>,严重程度节点 severity:<n>,问题行 diagnostic:<line>:<column>:<ordinal>:<fileKey>。ordinal 只数同一文件、同一位置上更早提交的问题,所以服务器重新发布、问题换了下标时,选中还停在同一条问题上。
  • rows 只含可见行:按文件或严重程度分组时,节点在深度 0、问题在深度 1,节点带 expanded;groupBy 为 none 时没有节点,问题都在深度 0,collapsed 不起作用。
  • shows 是这一行预览和打开的问题在提交列表里的下标:问题行是它自己,节点是它下面第一条。
  • 选中:键缺失或未知时不选中;问题被关着的节点挡住时,选中移到那个节点;问题已经消失时,按文件分组且文件还在则选中文件节点,否则不选中。selectedRow 是选中行在 rows 里的位置。
  • 文件分组的 name 是显示路径的最后一段,folder 是其余部分(在根目录时为空),宿主不再自己拆路径。

文档:rust/contracts/rust-core-api.md 的命令表和 lsp.problems.query 一节写入新字段、行键和选中规则;LspCommand::ProblemsQuery 的注释同步更新。

Fixture:rust/fixtures/lsp/problems-query-v1.json 原有用例补上 rows、selected 和文件分组的 name/folder,新增 6 个用例:

  • a closed file node hides its diagnostics and takes their selection
  • the selection follows a diagnostic the server republished at another index
  • a gone diagnostic selects its file node when the list is grouped by file
  • a gone diagnostic selects nothing when the list is grouped by severity
  • severity nodes close by key and keep a node selection
  • the ungrouped list ignores closed keys and selects only its diagnostics

宿主的桥接测试直接读这份 fixture,经真实 Core 比对。

插件契约:没有改 shared/plugins/、能力版本或 plugin-rpc,不需要更新协议更新记录,也不需要宿主方法表。

验证

命令 结果
cargo test -p lithe-core -- lsp_policy 10 通过(含 problems fixture 全部用例)
cargo clippy -p lithe-lsp-policy -p lithe-core --all-targets -- -D warnings、cargo fmt --all -- --check 通过
scripts/rust-core/verify-rust-core-comments.sh 通过
node scripts/rust-core/verify-platform-tests.mjs 通过
node shared/plugins/scripts/verify-docs.mjs 通过
宿主 desktop-go.sh test ./...(链接本分支 e270b7b) 通过;localshell 里一个已知偶发用例首轮失败,单独重跑通过,与本改动无关

后续

lsp.problems.query 接受平台保存的折叠分组键和选中行键,返回可见的树行
(分组节点在上,诊断在下;不分组时诊断在顶层)、选中行及其位置,文件
分组多返回 name 和 folder。诊断行键由文件、位置和同一位置上的序号组成,
服务器重新发布诊断后选中仍停在同一条上;被折叠的诊断选中移到所在节点,
消失的诊断在按文件分组时移到所在文件节点。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 17, 2026 12:12
@xiaoyumuxi
xiaoyumuxi merged commit cf2f260 into main Nov 17, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant