feat: add structural completion for mcpp.toml - #9
Merged
wellwei merged 3 commits intoAug 8, 2026
Conversation
Section-header snippets and writing templates for free-vocabulary sections, computed from a tolerant TOML parser that yields cursor contexts with explicit replacement ranges (unterminated input, CRLF, quoted/dotted keys, nested inline tables). Conditional sections such as [target.<sel>.dependencies] resolve to their base group. No static field keys/enums (waiting for a versioned upstream manifest schema) and no dynamic dependency data (waiting for a batch catalog interface); the completion query layer is provider-dispatch so both can be added back without touching the parser. Contract tests run every registered section header and template key through real mcpp builds (skipped where mcpp is absent). Gated by mcpp.tomlCompletion (default on).
This was referenced Aug 8, 2026
… 数组表不出建议、README 文档化 - SECTION_HEADERS 增加 [build-dependencies](mcpp 真实依赖表,契约测试已覆盖) - [[...]] 数组表段头不提供建议,避免把数组表意图悄悄替换成普通段 [x] - 补行为测试(数组表 / build-dependencies 模板)与段头注册表关键组断言 - README:能力矩阵、已实现功能、设置三处补充结构补全说明
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.
概要
为
mcpp.toml增加结构补全,依据设计 issue #8 的拆分结论,本 PR 只含可先落地的结构层。Supersedes #4。
提供的建议
[package]、[targets.<name>]、[dependencies]、[build-dependencies]、[indices]、[pack]等),参数化段带可跳转占位符;[dependencies]的五种依赖写法、[features]表形式、capabilities / xlings / tools.overrides / generated_files 等开放段的条目形态。
明确不含(#8 范围内留待后续,接口已预留)
(只读 env resolver 已由上游机器输出协议落地,见下)。
docs/zh/11-machine-output.md)已落地:--format json信封 +--protocol-version静态 effects 契约(
xpkg parseeffects 为空)、self env --format json只读。后续动态层将基于该协议接入,替代
--json裸输出与自研 home/shim 推导。实现
下钻;输出带 token 位置的光标上下文,每条建议携带显式替换范围,不产生
无效文本;
[target.'cfg(windows)'.dependencies]等正确识别;[[...]]数组表段头不提供建议(mcpp manifest 不使用 TOML 数组表,避免把数组表意图悄悄替换成普通段
[x]);extension.ts仅 1:1 映射;mcpp.tomlCompletion(resource 域,默认开启);未受信任工作区仅有纯文本补全,不执行任何外部程序(capabilities 描述已同步)。
测试
[build-dependencies])与模板(含实例)经真实mcpp build验证,含「条件段拒绝非 build-input 键」反向断言;无 mcpp 环境自动 skip;
已知缺口:vscode 胶水层(设置门 + 1:1 映射)无自动化测试,逻辑刻意压薄;
未知段被 mcpp 静默忽略,段头契约测试对「段被上游删除」不敏感(靠源码出处
注释 + 升级 diff 对照兜底)。