✨ feat(vscode): 代码阅读能读嵌在一种语言里的另一种语言的代码:语言插件报出是哪几段,宿主交给那种语言的插件只解析这几段、分步、翻成子块并叠着上色,外层翻译插件只问读出来的样子;契约加构建文件的几种块(解析指令、阶段、执行、复制、设置、标签、健康检查、启动)、分作用范围的变量、并成一块的几条语句,引擎排这些块的属性表
This commit is contained in:
1 parent
834673391e
commit
3353cf870c
11 files changed
+603
-103
No files matched your search
@@ -26,6 +26,7 @@ body {
|
||||
--cr-kind-comment: #6a9955;
|
||||
--cr-kind-options: #e5c07b;
|
||||
--cr-kind-command: #d7ba7d;
|
||||
--cr-kind-stage: #56b6c2;
|
||||
|
||||
margin: 0;
|
||||
font-family: var(--vscode-font-family, system-ui, sans-serif);
|
||||
@@ -60,23 +61,25 @@ body.vscode-high-contrast-light {
|
||||
--cr-kind-comment: #008000;
|
||||
--cr-kind-options: #9a6a00;
|
||||
--cr-kind-command: #7c5f12;
|
||||
--cr-kind-stage: #127f8c;
|
||||
}
|
||||
|
||||
/* 种类颜色:同一类语义共用一个颜色,图标区分具体是哪种(kindIcons.tsx)。卡片取自己的种类,子层取所属块的种类 */
|
||||
[data-kind="import"] { --kind: var(--cr-kind-import); }
|
||||
:is([data-kind="import"], [data-kind="copy"]) { --kind: var(--cr-kind-import); }
|
||||
[data-kind="function"] { --kind: var(--cr-kind-function); }
|
||||
:is([data-kind="class"], [data-kind="type"]) { --kind: var(--cr-kind-type); }
|
||||
[data-kind="enum"] { --kind: var(--cr-kind-enum); }
|
||||
[data-kind="exception"] { --kind: var(--cr-kind-exception); }
|
||||
:is([data-kind="field"], [data-kind="const"], [data-kind="variable"]) { --kind: var(--cr-kind-data); }
|
||||
:is([data-kind="field"], [data-kind="const"], [data-kind="variable"], [data-kind="label"]) { --kind: var(--cr-kind-data); }
|
||||
:is([data-kind="if"], [data-kind="else"], [data-kind="case"]) { --kind: var(--cr-kind-branch); }
|
||||
[data-kind="stage"] { --kind: var(--cr-kind-stage); }
|
||||
[data-kind="loop"] { --kind: var(--cr-kind-loop); }
|
||||
:is([data-kind="try"], [data-kind="catch"], [data-kind="finally"]) { --kind: var(--cr-kind-error); }
|
||||
[data-kind="return"] { --kind: var(--cr-kind-return); }
|
||||
:is([data-kind="statement"], [data-kind="interpreter"]) { --kind: var(--cr-kind-statement); }
|
||||
:is([data-kind="try"], [data-kind="catch"], [data-kind="finally"], [data-kind="health"]) { --kind: var(--cr-kind-error); }
|
||||
:is([data-kind="return"], [data-kind="start"]) { --kind: var(--cr-kind-return); }
|
||||
:is([data-kind="statement"], [data-kind="interpreter"], [data-kind="directive"]) { --kind: var(--cr-kind-statement); }
|
||||
[data-kind="comment"] { --kind: var(--cr-kind-comment); }
|
||||
[data-kind="options"] { --kind: var(--cr-kind-options); }
|
||||
:is([data-kind="command"], [data-kind="pipeline"]) { --kind: var(--cr-kind-command); }
|
||||
:is([data-kind="options"], [data-kind="setting"]) { --kind: var(--cr-kind-options); }
|
||||
:is([data-kind="command"], [data-kind="pipeline"], [data-kind="run"]) { --kind: var(--cr-kind-command); }
|
||||
/* 库规则认领的块:颜色由规则给,暗色、亮色两个写在元素的 style 上(--kind-dark / --kind-light),这里按主题挑 */
|
||||
[data-badge] { --kind: var(--kind-dark); }
|
||||
body:is(.vscode-light, .vscode-high-contrast-light) [data-badge] { --kind: var(--kind-light); }
|
||||
|
||||
@@ -36,6 +36,14 @@ describe('块的种类图标', () => {
|
||||
case: 'signpost',
|
||||
command: 'square-terminal',
|
||||
pipeline: 'square-terminal',
|
||||
directive: 'terminal',
|
||||
stage: 'layers',
|
||||
run: 'square-terminal',
|
||||
copy: 'copy',
|
||||
setting: 'sliders-horizontal',
|
||||
label: 'tag',
|
||||
health: 'activity',
|
||||
start: 'play',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,20 +2,24 @@ import type { LucideIcon } from 'lucide-react'
|
||||
import type { ReactElement } from 'react'
|
||||
import type { BlockKind, BlockView, KindIconName } from './types'
|
||||
import {
|
||||
Activity,
|
||||
Box,
|
||||
Braces,
|
||||
CalendarClock,
|
||||
Code,
|
||||
Copy,
|
||||
CornerDownLeft,
|
||||
CornerDownRight,
|
||||
Database,
|
||||
Globe,
|
||||
Import,
|
||||
Layers,
|
||||
ListOrdered,
|
||||
Lock,
|
||||
MessageSquareText,
|
||||
Network,
|
||||
Package,
|
||||
Play,
|
||||
Repeat,
|
||||
ServerCog,
|
||||
Shield,
|
||||
@@ -56,6 +60,10 @@ export const KIND_ICON_COMPONENTS: Record<KindIconName, LucideIcon> = {
|
||||
'sliders-horizontal': SlidersHorizontal,
|
||||
'signpost': Signpost,
|
||||
'square-terminal': SquareTerminal,
|
||||
'layers': Layers,
|
||||
'copy': Copy,
|
||||
'activity': Activity,
|
||||
'play': Play,
|
||||
'database': Database,
|
||||
'package': Package,
|
||||
'server-cog': ServerCog,
|
||||
@@ -92,6 +100,14 @@ export const KIND_ICONS: Record<BlockKind, KindIconName> = {
|
||||
case: 'signpost',
|
||||
command: 'square-terminal',
|
||||
pipeline: 'square-terminal',
|
||||
directive: 'terminal',
|
||||
stage: 'layers',
|
||||
run: 'square-terminal',
|
||||
copy: 'copy',
|
||||
setting: 'sliders-horizontal',
|
||||
label: 'tag',
|
||||
health: 'activity',
|
||||
start: 'play',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ export type BlockKind
|
||||
= | 'import' | 'function' | 'class' | 'enum' | 'exception' | 'type' | 'field' | 'const' | 'variable'
|
||||
| 'if' | 'else' | 'loop' | 'try' | 'catch' | 'finally' | 'return' | 'statement' | 'comment'
|
||||
| 'interpreter' | 'options' | 'case' | 'command' | 'pipeline'
|
||||
| 'directive' | 'stage' | 'run' | 'copy' | 'setting' | 'label' | 'health' | 'start'
|
||||
|
||||
/** 着色用的词性,源码着色和译文着色共用。 */
|
||||
export type TokenRole
|
||||
@@ -88,7 +89,8 @@ export interface ThemeColor { dark: string, light: string }
|
||||
export type KindIconName
|
||||
= | 'import' | 'square-function' | 'box' | 'braces' | 'list-ordered' | 'triangle-alert' | 'tag' | 'lock' | 'variable'
|
||||
| 'split' | 'corner-down-right' | 'repeat' | 'shield' | 'shield-alert' | 'shield-check' | 'corner-down-left' | 'code'
|
||||
| 'message-square-text' | 'terminal' | 'sliders-horizontal' | 'signpost' | 'square-terminal' | 'database' | 'package' | 'server-cog' | 'calendar-clock' | 'globe' | 'network'
|
||||
| 'message-square-text' | 'terminal' | 'sliders-horizontal' | 'signpost' | 'square-terminal' | 'layers' | 'copy' | 'activity' | 'play'
|
||||
| 'database' | 'package' | 'server-cog' | 'calendar-clock' | 'globe' | 'network'
|
||||
|
||||
/** 库规则的种类:名字(悬停提示、读屏念的文字)、颜色和图标(从 KindIconName 里挑);块左边只画图标 */
|
||||
export interface KindBadge { label: string, color: ThemeColor, icon: KindIconName }
|
||||
|
||||
Reference in new issue
Block a user