feat(view): mark prose-inferred params in Structure
Show inferred function parameters with a dashed chip and outline annotation so view surfaces v0.3 param elevation without changing the redundant call surfaces. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
551f4ff322
commit
4f09e515ee
4 files changed
+74
-3
No files matched your search
@@ -570,7 +570,7 @@ FnDef.params:
|
||||
| 4 | `` `n`+1 `` 误声明 | 建议 | 仅完整单个 code span `` `ident` `` 触发声明 |
|
||||
| 5 | 叙述强调斜体 vs 返回 | 建议 | 函数体内合法返回表达式才当返回;否则当文字 |
|
||||
| 6 | 一行多 `**…**` | **建议采纳** | 允许,按出现序执行(M0 钉死为是) |
|
||||
| 7 | view 展示 prose Decl | 建议 | Variables 列绑定图 + 标注是否已升参 |
|
||||
| 7 | view 展示 prose Decl | **已落地** | Structure / Functions 大纲:`inferred` 形参标注(`chip inferred`) |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
### M4 — 双后端与工具
|
||||
|
||||
- [x] 字节码发射跟随新 Stmt 源
|
||||
- [ ] `view` / Variables:显示推断形参与 prose Decl
|
||||
- [x] `view` / Structure:推断形参 `chip inferred` + Functions 大纲标注
|
||||
- [ ] (可选)`marqdo migrate markup-v03` 机械改写提示/工具
|
||||
|
||||
**出门:** tree 与 bytecode 后端对 `markup-v03` 金样一致。
|
||||
|
||||
@@ -355,6 +355,16 @@ section.block > h2 {
|
||||
border: 1px solid transparent;
|
||||
color: var(--ink);
|
||||
}
|
||||
.chip.inferred {
|
||||
border-style: dashed;
|
||||
border-color: var(--line);
|
||||
opacity: 0.92;
|
||||
}
|
||||
.chip.inferred::after {
|
||||
content: " ↑";
|
||||
font-size: 0.65em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.nested {
|
||||
margin: 0.45rem 0 0.15rem 0.15rem;
|
||||
padding-left: 0.85rem;
|
||||
@@ -684,6 +694,15 @@ section.block > h2 {
|
||||
font-size: 0.66rem;
|
||||
margin-left: 0.2rem;
|
||||
}
|
||||
.outline-item .ol-params {
|
||||
margin-left: 0.25rem;
|
||||
font-family: var(--mono);
|
||||
font-size: 0.62rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
.outline-item .ol-param.inferred {
|
||||
border-bottom: 1px dashed var(--line);
|
||||
}
|
||||
.fun-card:target {
|
||||
outline: 2px solid var(--focus);
|
||||
outline-offset: 2px;
|
||||
|
||||
+53
-1
@@ -812,6 +812,26 @@ fn outline_fun(fun: &Function, parent_path: &str) -> String {
|
||||
escape(&fun.name),
|
||||
fun.level,
|
||||
);
|
||||
if !fun.params.is_empty() {
|
||||
s.push_str(" <span class=\"ol-params\">");
|
||||
for (i, p) in fun.params.iter().enumerate() {
|
||||
if i > 0 {
|
||||
s.push(' ');
|
||||
}
|
||||
if p.inferred {
|
||||
s.push_str(&format!(
|
||||
"<span class=\"ol-param inferred\" title=\"inferred\">{}</span>",
|
||||
escape(&p.name)
|
||||
));
|
||||
} else {
|
||||
s.push_str(&format!(
|
||||
"<span class=\"ol-param\" title=\"explicit\">{}</span>",
|
||||
escape(&p.name)
|
||||
));
|
||||
}
|
||||
}
|
||||
s.push_str("</span>");
|
||||
}
|
||||
if !fun.children.is_empty() {
|
||||
s.push_str("<ul>");
|
||||
for child in &fun.children {
|
||||
@@ -920,7 +940,17 @@ fn render_fun(
|
||||
if !fun.params.is_empty() {
|
||||
s.push_str("<div class=\"params\">");
|
||||
for p in &fun.params {
|
||||
s.push_str(&format!("<span class=\"chip\">{}</span>", escape(&p.name)));
|
||||
let (cls, title) = if p.inferred {
|
||||
("chip inferred", "inferred from prose / body")
|
||||
} else {
|
||||
("chip", "explicit + param")
|
||||
};
|
||||
s.push_str(&format!(
|
||||
"<span class=\"{cls}\" title=\"{title}\">{name}</span>",
|
||||
cls = cls,
|
||||
title = title,
|
||||
name = escape(&p.name),
|
||||
));
|
||||
}
|
||||
s.push_str("</div>");
|
||||
}
|
||||
@@ -1625,6 +1655,28 @@ mod tests {
|
||||
assert!(html.contains(">xs<") || html.contains("vars-name\">xs"), "{html}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_marks_inferred_params() {
|
||||
let src = include_str!("../../tests/markup-v03/inc-prose.mq.md");
|
||||
let module = crate::parse::parse_source(src).unwrap();
|
||||
let add = module
|
||||
.functions
|
||||
.iter()
|
||||
.find(|f| f.name == "加一函数")
|
||||
.expect("加一函数");
|
||||
assert!(add.params.iter().any(|p| p.name == "n" && p.inferred));
|
||||
let html = render_module_structure(&module, src);
|
||||
assert!(
|
||||
html.contains("chip inferred") && html.contains(">n<"),
|
||||
"expected inferred chip for n: {html}"
|
||||
);
|
||||
let outline = render_function_outline(&module);
|
||||
assert!(
|
||||
outline.contains("ol-param inferred") && outline.contains(">n<"),
|
||||
"expected outline inferred param: {outline}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_panel_gated_on_llm_or_agent_import() {
|
||||
let hello = crate::parse::parse_source(include_str!("../../tests/structure/hello.mq.md"))
|
||||
|
||||
Reference in new issue
Block a user