✨ feat(vscode): 代码阅读的链式调用卡片:语言插件读链、翻译模板排成起点和步骤
契约加 LanguageAdapter.chain、Translator.chain、RuleContext.chain、PropertyRow.chain、TextTranslation.rows;跨行写或实参里有闭包的链排成卡片,连着同名调用合成一步列出每次实参,注释挂在步骤上,闭包收起、子块挂到那一步(BlockView.step);Rust 插件读链、标准库常见方法写中文名;挤成一行时另起一行的 . 贴着前面
This commit is contained in:
1 parent
80eda7c18e
commit
ee595f3da9
16 files changed
+1041
-72
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { BlockView } from '../blockView'
|
||||
import type { Inline, PreviewTable, PreviewText, PropertyItem, PropertyRow, Segment, SourceRange } from '../contract'
|
||||
import type { ChainStep, Inline, PreviewTable, PreviewText, PropertyItem, PropertyRow, Segment, SourceRange } from '../contract'
|
||||
import type { BlockMarks, ItemDiff, ItemsDiff, RowDiff, RowsDiff, TextDiff } from '../diff/viewDiff'
|
||||
import type { BlockSpan, PageBlock, PageCard } from './messages'
|
||||
import { createHash } from 'node:crypto'
|
||||
@@ -70,6 +70,19 @@ function shiftRow(row: PropertyRow, base: number): PropertyRow {
|
||||
value: shiftText(row.value, base),
|
||||
...(row.defines && { defines: shiftRange(row.defines, base) }),
|
||||
...(row.items && { items: row.items.map(item => shiftItem(item, base)) }),
|
||||
...(row.chain && { chain: row.chain.map(step => shiftStep(step, base)) }),
|
||||
}
|
||||
}
|
||||
|
||||
function shiftStep(step: ChainStep, base: number): ChainStep {
|
||||
return {
|
||||
...step,
|
||||
name: shiftInline(step.name, base),
|
||||
value: shiftInline(step.value, base),
|
||||
...(step.lines && { lines: step.lines.map(line => shiftInline(line, base)) }),
|
||||
...(step.rows && { rows: step.rows.map(row => shiftRow(row, base)) }),
|
||||
...(step.table && { table: shiftTable(step.table, base) }),
|
||||
range: shiftRange(step.range, base),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +98,7 @@ export function pageCard(block: BlockView, base: number): PageCard {
|
||||
...(block.commentTarget && { commentTarget: block.commentTarget.kind }),
|
||||
...(block.badge && { badge: block.badge }),
|
||||
...(block.slot && { slot: block.slot }),
|
||||
...(block.step && { step: block.step }),
|
||||
...(block.callTree && { callTree: block.callTree }),
|
||||
}
|
||||
if ('properties' in block)
|
||||
|
||||
Reference in new issue
Block a user