✨ feat(vscode): 代码阅读的块种类只画图标(lucide,种类色),种类名放进鼠标停上去的提示和读屏文字;库规则给自己的图标
This commit is contained in:
1 parent
33a1b5d57c
commit
1dfc0c7b1e
19 files changed
+185
-56
No files matched your search
@@ -32,7 +32,7 @@ function cardRule(id: string, overrides: Partial<RuleBlock> = {}): LibraryRule {
|
||||
languageIds: ['python'],
|
||||
libraries: ['sqlalchemy'],
|
||||
claim: block => block.kind === 'class'
|
||||
? { kind: `${id}.card`, badge: { label: `${id} 卡片`, color: { dark: '#fff', light: '#000' } }, rows: [], absorbs: block.children.slice(0, 1), ...overrides }
|
||||
? { kind: `${id}.card`, badge: { label: `${id} 卡片`, color: { dark: '#fff', light: '#000' }, icon: 'box' }, rows: [], absorbs: block.children.slice(0, 1), ...overrides }
|
||||
: undefined,
|
||||
}
|
||||
}
|
||||
@@ -91,14 +91,14 @@ describe('库规则:启用', () => {
|
||||
})
|
||||
|
||||
describe('库规则:认领', () => {
|
||||
it('认领的块换成替身:种类、标签、编辑范围是整个类;规则没并进来的子块(夹在中间的注释、方法)照源码顺序留下', async () => {
|
||||
it('认领的块换成替身:种类、badge、编辑范围是整个类;规则没并进来的子块(夹在中间的注释、方法)照源码顺序留下', async () => {
|
||||
const rule: LibraryRule = {
|
||||
...cardRule('orm'),
|
||||
claim: (block) => {
|
||||
if (block.kind !== 'class')
|
||||
return undefined
|
||||
const [table, , column] = block.children
|
||||
return { kind: 'orm.card', badge: { label: '卡片', color: { dark: '#fff', light: '#000' } }, rows: [{ label: '名称', value: [{ text: 'User', role: 'type' }] }], absorbs: [table, column] }
|
||||
return { kind: 'orm.card', badge: { label: '卡片', color: { dark: '#fff', light: '#000' }, icon: 'box' }, rows: [{ label: '名称', value: [{ text: 'User', role: 'type' }] }], absorbs: [table, column] }
|
||||
},
|
||||
}
|
||||
const [, card] = await views(MODEL, [rule])
|
||||
@@ -128,7 +128,7 @@ describe('库规则:认领', () => {
|
||||
'',
|
||||
].join('\n')
|
||||
const fields: LibraryRule = { ...cardRule('orm'), claim: block => block.kind === 'class'
|
||||
? { kind: 'orm.card', badge: { label: '卡片', color: { dark: '#fff', light: '#000' } }, rows: [], absorbs: block.children.filter(child => child.kind === 'variable') }
|
||||
? { kind: 'orm.card', badge: { label: '卡片', color: { dark: '#fff', light: '#000' }, icon: 'box' }, rows: [], absorbs: block.children.filter(child => child.kind === 'variable') }
|
||||
: undefined }
|
||||
const [, card] = await views(source, [fields])
|
||||
expect(card.children.map(child => [child.kind, child.startLine, child.endLine])).toEqual([['function', 5, 5]])
|
||||
@@ -198,7 +198,7 @@ describe('库规则:认领', () => {
|
||||
expect(reports).toEqual(['库规则 lib 给第 3 行的 class 块的替身不合约定,这块照常显示:要并进来的块不是这块的子块'])
|
||||
})
|
||||
|
||||
it('筛选:规则的种类和别的种类一样计数,名字取规则给的标签', async () => {
|
||||
it('筛选:规则的种类和别的种类一样计数,名字取规则给的名字(badge.label)', async () => {
|
||||
const list = await views(MODEL, [cardRule('orm')])
|
||||
expect(fileAttributes(list, pythonZhTranslator.attributeNames).find(attribute => attribute.id === 'kind')?.values).toEqual([
|
||||
{ id: 'import', name: '导入', count: 1 },
|
||||
|
||||
Reference in new issue
Block a user