✨ feat(vscode): React 钩子卡片按变量讲,属性表加操作列、调用树能查所有引用

- 钩子调用讲成状态、引用、记忆值、记忆函数、上下文值、过渡、副作用、钩子返回值、钩子调用几种卡片,行照签名表 reactHooks.ts 排,去掉 react.hook
- 解构接住时名称一行写出解构,展开是「第几项 | 名称 | 说明」表,每项一个调用树操作;单个名字的按钮在名称一行最右边
- 属性表的行、子行可以带操作(RowAction),表格多一列「操作」,宿主按块记号加序号起键
- 调用树服务按键数次数,新增查所有引用(references):按所在函数分组,去掉定义处和依赖数组里的
- 钩子收的函数参数都收成小框,函数体是卡片子块,直接返回的表达式由 functionBody 排成「返回 …」卡片;小框和卡片折叠箭头同一个开关
- 规则卡片可指定语言种类图标(languageKind)、种类图标悬停字和颜色(KindBadge.tooltip / iconColor)
This commit is contained in:
cruldra committed 2026-10-16 22:16:09 +11:00
1 parent a139341132
commit 86beaac371
38 files changed
+1971 -813

No files matched your search

+9 -2
View File
@@ -1,5 +1,5 @@
import type { BlockView } from '../blockView'
import type { ChainStep, Inline, PreviewTable, PreviewText, PropertyItem, PropertyRow, Segment, SourceRange } from '../contract'
import type { ChainStep, Inline, PreviewTable, PreviewText, PropertyItem, PropertyRow, RowAction, 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'
@@ -50,6 +50,11 @@ function shiftText(text: PreviewText, base: number): PreviewText {
return 'markdown' in text ? text : shiftInline(text, base)
}
/** 一个操作查的名字、不算的范围按块的开头算;键原样留着(页面按它对次数)。 */
function shiftAction(action: RowAction, base: number): RowAction {
return { ...action, name: shiftRange(action.name, base), ...(action.except && { except: action.except.map(range => shiftRange(range, base)) }) }
}
function shiftItem(item: PropertyItem, base: number): PropertyItem {
return {
...item,
@@ -57,6 +62,7 @@ function shiftItem(item: PropertyItem, base: number): PropertyItem {
...(item.defines && { defines: shiftRange(item.defines, base) }),
...(item.items && { items: item.items.map(inner => shiftItem(inner, base)) }),
...(item.table && { table: shiftTable(item.table, base) }),
...(item.actions && { actions: item.actions.map(action => shiftAction(action, base)) }),
}
}
@@ -71,6 +77,7 @@ function shiftRow(row: PropertyRow, base: number): PropertyRow {
...(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)) }),
...(row.actions && { actions: row.actions.map(action => shiftAction(action, base)) }),
}
}
@@ -100,7 +107,7 @@ export function pageCard(block: BlockView, base: number): PageCard {
...(block.tint && { tint: block.tint }),
...(block.slot && { slot: block.slot }),
...(block.step && { step: block.step }),
...(block.callTree && { callTree: block.callTree.name ? { ...block.callTree, name: shiftRange(block.callTree.name, base) } : block.callTree }),
...(block.callTree && { callTree: block.callTree }),
}
if ('properties' in block)
return { ...card, properties: block.properties.map(row => shiftRow(row, base)) }