✨ 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 { DisplayName, IndexEntry, Inline, LanguageAdapter, NameBinding, PreviewText, PropertyItem, RuleLocation } from './contract'
|
||||
import type { DisplayName, IndexEntry, Inline, LanguageAdapter, NameBinding, PreviewText, PropertyItem, PropertyRow, RuleLocation } from './contract'
|
||||
import type { IndexedEntry, WorkspaceIndexOf } from './workspaceIndex'
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ export interface ShownName {
|
||||
definition?: true
|
||||
}
|
||||
|
||||
/** 视图数据里照抄自源码、带下标的名字(一行译文和它下面拆开的各项、表,属性表的值、各层子行的格子、框里):下标 → 原文。 */
|
||||
/** 视图数据里照抄自源码、带下标的名字(一行译文和它下面拆开的各项、表、几行属性,属性表的值、各层子行的格子、链式调用的各步、框里):下标 → 原文。 */
|
||||
export function renderedNames(blocks: readonly BlockView[]): Map<number, string> {
|
||||
const found = new Map<number, string>()
|
||||
const inline = (pieces: readonly Inline[]): void => {
|
||||
@@ -37,18 +37,29 @@ export function renderedNames(blocks: readonly BlockView[]): Map<number, string>
|
||||
items(item.table?.items)
|
||||
}
|
||||
}
|
||||
const rows = (list: readonly PropertyRow[] | undefined): void => {
|
||||
for (const row of list ?? []) {
|
||||
text(row.value)
|
||||
items(row.items)
|
||||
for (const step of row.chain ?? []) {
|
||||
inline(step.name)
|
||||
inline(step.value)
|
||||
step.lines?.forEach(inline)
|
||||
rows(step.rows)
|
||||
items(step.table?.items)
|
||||
}
|
||||
}
|
||||
}
|
||||
const visit = (list: readonly BlockView[]): void => {
|
||||
for (const block of list) {
|
||||
if ('properties' in block) {
|
||||
for (const row of block.properties) {
|
||||
text(row.value)
|
||||
items(row.items)
|
||||
}
|
||||
rows(block.properties)
|
||||
}
|
||||
else {
|
||||
text(block.translation)
|
||||
items(block.items)
|
||||
items(block.table?.items)
|
||||
rows(block.rows)
|
||||
}
|
||||
visit(block.children)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user