@likec4/language-server 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +21 -0
- package/dist/browser.d.cts +22 -0
- package/dist/browser.d.mts +22 -0
- package/dist/browser.d.ts +22 -0
- package/dist/browser.mjs +19 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +1 -0
- package/dist/likec4lib.cjs +961 -0
- package/dist/likec4lib.d.cts +6 -0
- package/dist/likec4lib.d.mts +6 -0
- package/dist/likec4lib.d.ts +6 -0
- package/dist/likec4lib.mjs +957 -0
- package/dist/model-graph/index.cjs +10 -0
- package/dist/model-graph/index.d.cts +79 -0
- package/dist/model-graph/index.d.mts +79 -0
- package/dist/model-graph/index.d.ts +79 -0
- package/dist/model-graph/index.mjs +1 -0
- package/dist/node.cjs +18 -0
- package/dist/node.d.cts +20 -0
- package/dist/node.d.mts +20 -0
- package/dist/node.d.ts +20 -0
- package/dist/node.mjs +16 -0
- package/dist/protocol.cjs +25 -0
- package/dist/protocol.d.cts +43 -0
- package/dist/protocol.d.mts +43 -0
- package/dist/protocol.d.ts +43 -0
- package/dist/protocol.mjs +17 -0
- package/dist/shared/language-server.86lmJ8ZN.d.cts +1194 -0
- package/dist/shared/language-server.B1TZgyoH.cjs +5371 -0
- package/dist/shared/language-server.CCB4ESN5.mjs +1606 -0
- package/dist/shared/language-server.CFTY6j4e.d.mts +1194 -0
- package/dist/shared/language-server.D0bOlrCi.cjs +1619 -0
- package/dist/shared/language-server.Q-wtPShM.mjs +5360 -0
- package/dist/shared/language-server.RjhrBZS0.d.ts +1194 -0
- package/package.json +35 -20
- package/src/ast.ts +40 -30
- package/src/browser.ts +0 -3
- package/src/elementRef.ts +1 -1
- package/src/generated/ast.ts +67 -3
- package/src/generated/grammar.ts +1 -1
- package/src/generated-lib/icons.ts +1 -1
- package/src/like-c4.langium +16 -2
- package/src/likec4lib.ts +2 -3
- package/src/logger.ts +9 -1
- package/src/lsp/RenameProvider.ts +8 -0
- package/src/lsp/SemanticTokenProvider.ts +19 -1
- package/src/lsp/index.ts +1 -0
- package/src/model/fqn-computation.ts +33 -23
- package/src/model/fqn-index.ts +5 -20
- package/src/model/model-builder.ts +147 -90
- package/src/model/model-locator.ts +1 -1
- package/src/model/model-parser-where.ts +3 -2
- package/src/model/model-parser.ts +57 -19
- package/src/model-graph/LikeC4ModelGraph.ts +42 -21
- package/src/model-graph/compute-view/__test__/fixture.ts +16 -14
- package/src/model-graph/compute-view/compute.ts +9 -6
- package/src/model-graph/compute-view/predicates.ts +3 -3
- package/src/model-graph/dynamic-view/__test__/fixture.ts +1 -0
- package/src/model-graph/dynamic-view/compute.ts +2 -1
- package/src/model-graph/utils/elementExpressionToPredicate.ts +1 -1
- package/src/model-graph/utils/sortNodes.ts +2 -6
- package/src/module.ts +23 -3
- package/src/protocol.ts +4 -5
- package/src/references/scope-computation.ts +10 -1
- package/src/references/scope-provider.ts +2 -1
- package/src/shared/NodeKindProvider.ts +73 -34
- package/src/test/setup.ts +3 -8
- package/src/utils/graphlib.ts +11 -0
- package/src/view-utils/manual-layout.ts +1 -1
- package/src/view-utils/resolve-extended-views.ts +19 -10
- package/src/view-utils/resolve-relative-paths.ts +5 -7
- package/src/view-utils/view-hash.ts +1 -1
- package/src/reset.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-server",
|
|
3
3
|
"description": "LikeC4 Language Server",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -21,30 +21,37 @@
|
|
|
21
21
|
"directory": "packages/language-server"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
24
25
|
"exports": {
|
|
25
26
|
".": {
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
27
|
-
"
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.cjs"
|
|
28
30
|
},
|
|
29
31
|
"./likec4lib": {
|
|
30
32
|
"types": "./dist/likec4lib.d.ts",
|
|
31
|
-
"
|
|
33
|
+
"import": "./dist/likec4lib.mjs",
|
|
34
|
+
"require": "./dist/likec4lib.cjs"
|
|
32
35
|
},
|
|
33
36
|
"./browser": {
|
|
34
37
|
"types": "./dist/browser.d.ts",
|
|
35
|
-
"
|
|
38
|
+
"import": "./dist/browser.mjs",
|
|
39
|
+
"require": "./dist/browser.cjs"
|
|
36
40
|
},
|
|
37
41
|
"./protocol": {
|
|
38
42
|
"types": "./dist/protocol.d.ts",
|
|
39
|
-
"
|
|
43
|
+
"import": "./dist/protocol.mjs",
|
|
44
|
+
"require": "./dist/protocol.cjs"
|
|
40
45
|
},
|
|
41
46
|
"./node": {
|
|
42
47
|
"types": "./dist/node.d.ts",
|
|
43
|
-
"
|
|
48
|
+
"import": "./dist/node.mjs",
|
|
49
|
+
"require": "./dist/node.cjs"
|
|
44
50
|
},
|
|
45
51
|
"./model-graph": {
|
|
46
52
|
"types": "./dist/model-graph/index.d.ts",
|
|
47
|
-
"
|
|
53
|
+
"import": "./dist/model-graph/index.mjs",
|
|
54
|
+
"require": "./dist/model-graph/index.cjs"
|
|
48
55
|
}
|
|
49
56
|
},
|
|
50
57
|
"publishConfig": {
|
|
@@ -53,32 +60,40 @@
|
|
|
53
60
|
"exports": {
|
|
54
61
|
".": {
|
|
55
62
|
"types": "./dist/index.d.ts",
|
|
56
|
-
"
|
|
63
|
+
"import": "./dist/index.mjs",
|
|
64
|
+
"require": "./dist/index.cjs"
|
|
57
65
|
},
|
|
58
66
|
"./likec4lib": {
|
|
59
67
|
"types": "./dist/likec4lib.d.ts",
|
|
60
|
-
"
|
|
68
|
+
"import": "./dist/likec4lib.mjs",
|
|
69
|
+
"require": "./dist/likec4lib.cjs"
|
|
61
70
|
},
|
|
62
71
|
"./browser": {
|
|
63
72
|
"types": "./dist/browser.d.ts",
|
|
64
|
-
"
|
|
73
|
+
"import": "./dist/browser.mjs",
|
|
74
|
+
"require": "./dist/browser.cjs"
|
|
65
75
|
},
|
|
66
76
|
"./protocol": {
|
|
67
77
|
"types": "./dist/protocol.d.ts",
|
|
68
|
-
"
|
|
78
|
+
"import": "./dist/protocol.mjs",
|
|
79
|
+
"require": "./dist/protocol.cjs"
|
|
69
80
|
},
|
|
70
81
|
"./node": {
|
|
71
82
|
"types": "./dist/node.d.ts",
|
|
72
|
-
"
|
|
83
|
+
"import": "./dist/node.mjs",
|
|
84
|
+
"require": "./dist/node.cjs"
|
|
73
85
|
},
|
|
74
86
|
"./model-graph": {
|
|
75
87
|
"types": "./dist/model-graph/index.d.ts",
|
|
76
|
-
"
|
|
88
|
+
"import": "./dist/model-graph/index.mjs",
|
|
89
|
+
"require": "./dist/model-graph/index.cjs"
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
},
|
|
80
93
|
"scripts": {
|
|
81
94
|
"typecheck": "tsc --noEmit",
|
|
95
|
+
"prepack": "turbo run build",
|
|
96
|
+
"build": "unbuild",
|
|
82
97
|
"pregenerate": "rm -f src/generated/*",
|
|
83
98
|
"watch:langium": "langium generate --watch",
|
|
84
99
|
"watch:ts": "tsc --watch",
|
|
@@ -92,11 +107,10 @@
|
|
|
92
107
|
},
|
|
93
108
|
"dependencies": {
|
|
94
109
|
"@dagrejs/graphlib": "^2.2.4",
|
|
95
|
-
"@likec4/core": "1.
|
|
96
|
-
"@likec4/log": "1.
|
|
110
|
+
"@likec4/core": "1.9.0",
|
|
111
|
+
"@likec4/log": "1.9.0",
|
|
97
112
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
98
113
|
"@smithy/util-base64": "^3.0.0",
|
|
99
|
-
"@total-typescript/ts-reset": "^0.5.1",
|
|
100
114
|
"fast-equals": "^5.0.1",
|
|
101
115
|
"indent-string": "^5.0.0",
|
|
102
116
|
"json5": "^2.2.3",
|
|
@@ -106,7 +120,7 @@
|
|
|
106
120
|
"remeda": "^2.11.0",
|
|
107
121
|
"string-hash": "^1.1.3",
|
|
108
122
|
"strip-indent": "^4.0.0",
|
|
109
|
-
"type-fest": "^4.
|
|
123
|
+
"type-fest": "^4.26.0",
|
|
110
124
|
"ufo": "^1.5.4",
|
|
111
125
|
"vscode-jsonrpc": "8.2.0",
|
|
112
126
|
"vscode-languageserver": "9.0.1",
|
|
@@ -114,17 +128,18 @@
|
|
|
114
128
|
"vscode-uri": "3.0.8"
|
|
115
129
|
},
|
|
116
130
|
"devDependencies": {
|
|
117
|
-
"@likec4/icons": "1.
|
|
118
|
-
"@likec4/tsconfig": "1.
|
|
131
|
+
"@likec4/icons": "1.9.0",
|
|
132
|
+
"@likec4/tsconfig": "1.9.0",
|
|
119
133
|
"@types/node": "^20.16.1",
|
|
120
134
|
"@types/object-hash": "^3.0.6",
|
|
121
135
|
"@types/string-hash": "^1.1.3",
|
|
122
136
|
"execa": "^9.3.1",
|
|
123
|
-
"glob": "^11.0.0",
|
|
124
137
|
"langium-cli": "3.1.1",
|
|
125
138
|
"npm-run-all2": "^6.2.2",
|
|
126
139
|
"tsx": "~4.9.3",
|
|
140
|
+
"turbo": "^2.1.1",
|
|
127
141
|
"typescript": "^5.5.4",
|
|
142
|
+
"unbuild": "^3.0.0-rc.7",
|
|
128
143
|
"vitest": "~2.0.5"
|
|
129
144
|
},
|
|
130
145
|
"packageManager": "yarn@4.3.1"
|
package/src/ast.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DefaultArrowType,
|
|
4
|
-
DefaultLineStyle,
|
|
5
|
-
DefaultRelationshipColor,
|
|
6
|
-
nonexhaustive,
|
|
7
|
-
RelationRefError
|
|
8
|
-
} from '@likec4/core'
|
|
1
|
+
import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor, nonexhaustive } from '@likec4/core'
|
|
2
|
+
import type * as c4 from '@likec4/core'
|
|
9
3
|
import type { AstNode, AstNodeDescription, DiagnosticInfo, LangiumDocument, MultiMap } from 'langium'
|
|
10
4
|
import { DocumentState } from 'langium'
|
|
11
5
|
import { clamp, isDefined, isNullish, isTruthy } from 'remeda'
|
|
@@ -36,13 +30,14 @@ declare module './generated/ast' {
|
|
|
36
30
|
type ParsedElementStyle = {
|
|
37
31
|
shape?: c4.ElementShape
|
|
38
32
|
icon?: c4.IconUrl
|
|
39
|
-
color?: c4.
|
|
33
|
+
color?: c4.Color
|
|
40
34
|
border?: c4.BorderStyle
|
|
41
35
|
opacity?: number
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
export interface ParsedAstSpecification {
|
|
45
|
-
|
|
39
|
+
tags: Set<c4.Tag>
|
|
40
|
+
elements: Record<c4.ElementKind, {
|
|
46
41
|
technology?: string
|
|
47
42
|
notation?: string
|
|
48
43
|
style: ParsedElementStyle
|
|
@@ -52,12 +47,18 @@ export interface ParsedAstSpecification {
|
|
|
52
47
|
{
|
|
53
48
|
technology?: string
|
|
54
49
|
notation?: string
|
|
55
|
-
color?: c4.
|
|
50
|
+
color?: c4.Color
|
|
56
51
|
line?: c4.RelationshipLineType
|
|
57
52
|
head?: c4.RelationshipArrowType
|
|
58
53
|
tail?: c4.RelationshipArrowType
|
|
59
54
|
}
|
|
60
55
|
>
|
|
56
|
+
colors: Record<
|
|
57
|
+
c4.CustomColor,
|
|
58
|
+
{
|
|
59
|
+
color: c4.HexColorLiteral
|
|
60
|
+
}
|
|
61
|
+
>
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export interface ParsedAstElement {
|
|
@@ -83,7 +84,7 @@ export interface ParsedAstRelation {
|
|
|
83
84
|
title: string
|
|
84
85
|
description?: string
|
|
85
86
|
technology?: string
|
|
86
|
-
color?: c4.
|
|
87
|
+
color?: c4.Color
|
|
87
88
|
line?: c4.RelationshipLineType
|
|
88
89
|
head?: c4.RelationshipArrowType
|
|
89
90
|
tail?: c4.RelationshipArrowType
|
|
@@ -181,8 +182,10 @@ export interface ParsedLikeC4LangiumDocument
|
|
|
181
182
|
export function cleanParsedModel(doc: LikeC4LangiumDocument) {
|
|
182
183
|
const props: Required<Omit<LikeC4DocumentProps, 'c4fqnIndex' | 'diagnostics'>> = {
|
|
183
184
|
c4Specification: {
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
tags: new Set(),
|
|
186
|
+
elements: {},
|
|
187
|
+
relationships: {},
|
|
188
|
+
colors: {}
|
|
186
189
|
},
|
|
187
190
|
c4Elements: [],
|
|
188
191
|
c4Relations: [],
|
|
@@ -247,6 +250,7 @@ const isValidatableAstNode = validatableAstNodeGuards([
|
|
|
247
250
|
ast.isSpecificationElementKind,
|
|
248
251
|
ast.isSpecificationRelationshipKind,
|
|
249
252
|
ast.isSpecificationTag,
|
|
253
|
+
ast.isSpecificationColor,
|
|
250
254
|
ast.isSpecificationRule,
|
|
251
255
|
ast.isModelViews,
|
|
252
256
|
ast.isModel
|
|
@@ -279,8 +283,9 @@ export function checksFromDiagnostics(doc: LikeC4LangiumDocument) {
|
|
|
279
283
|
}
|
|
280
284
|
}
|
|
281
285
|
export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>
|
|
286
|
+
export type IsValidFn = ChecksFromDiagnostics['isValid']
|
|
282
287
|
|
|
283
|
-
export function* streamModel(doc: LikeC4LangiumDocument, isValid:
|
|
288
|
+
export function* streamModel(doc: LikeC4LangiumDocument, isValid: IsValidFn) {
|
|
284
289
|
const traverseStack = doc.parseResult.value.models.flatMap(m => (isValid(m) ? m.elements : []))
|
|
285
290
|
const relations = [] as ast.Relation[]
|
|
286
291
|
let el
|
|
@@ -299,13 +304,7 @@ export function* streamModel(doc: LikeC4LangiumDocument, isValid: ChecksFromDiag
|
|
|
299
304
|
continue
|
|
300
305
|
}
|
|
301
306
|
if (el.body && el.body.elements.length > 0) {
|
|
302
|
-
|
|
303
|
-
if (ast.isRelation(nested)) {
|
|
304
|
-
relations.push(nested)
|
|
305
|
-
} else {
|
|
306
|
-
traverseStack.push(nested)
|
|
307
|
-
}
|
|
308
|
-
}
|
|
307
|
+
traverseStack.push(...el.body.elements)
|
|
309
308
|
}
|
|
310
309
|
yield el
|
|
311
310
|
}
|
|
@@ -320,12 +319,12 @@ export function resolveRelationPoints(node: ast.Relation): {
|
|
|
320
319
|
} {
|
|
321
320
|
const target = elementRef(node.target)
|
|
322
321
|
if (!target) {
|
|
323
|
-
throw new
|
|
322
|
+
throw new Error('RelationRefError: Invalid reference to target')
|
|
324
323
|
}
|
|
325
324
|
if (isDefined(node.source)) {
|
|
326
325
|
const source = elementRef(node.source)
|
|
327
326
|
if (!source) {
|
|
328
|
-
throw new
|
|
327
|
+
throw new Error('RelationRefError: Invalid reference to source')
|
|
329
328
|
}
|
|
330
329
|
return {
|
|
331
330
|
source,
|
|
@@ -333,7 +332,7 @@ export function resolveRelationPoints(node: ast.Relation): {
|
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
334
|
if (!ast.isElementBody(node.$container)) {
|
|
336
|
-
throw new
|
|
335
|
+
throw new Error('RelationRefError: Invalid container for sourceless relation')
|
|
337
336
|
}
|
|
338
337
|
return {
|
|
339
338
|
source: node.$container.$container,
|
|
@@ -346,12 +345,15 @@ export function parseAstOpacityProperty({ value }: ast.OpacityProperty): number
|
|
|
346
345
|
return isNaN(opacity) ? 100 : clamp(opacity, { min: 0, max: 100 })
|
|
347
346
|
}
|
|
348
347
|
|
|
349
|
-
export function toElementStyle(props
|
|
348
|
+
export function toElementStyle(props: Array<ast.StyleProperty> | undefined, isValid: IsValidFn) {
|
|
350
349
|
const result = {} as ParsedElementStyle
|
|
351
350
|
if (!props || props.length === 0) {
|
|
352
351
|
return result
|
|
353
352
|
}
|
|
354
353
|
for (const prop of props) {
|
|
354
|
+
if (!isValid(prop)) {
|
|
355
|
+
continue
|
|
356
|
+
}
|
|
355
357
|
switch (true) {
|
|
356
358
|
case ast.isBorderProperty(prop): {
|
|
357
359
|
if (isTruthy(prop.value)) {
|
|
@@ -360,8 +362,9 @@ export function toElementStyle(props?: Array<ast.StyleProperty>) {
|
|
|
360
362
|
break
|
|
361
363
|
}
|
|
362
364
|
case ast.isColorProperty(prop): {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
const color = toColor(prop)
|
|
366
|
+
if (isTruthy(color)) {
|
|
367
|
+
result.color = color
|
|
365
368
|
}
|
|
366
369
|
break
|
|
367
370
|
}
|
|
@@ -392,7 +395,7 @@ export function toElementStyle(props?: Array<ast.StyleProperty>) {
|
|
|
392
395
|
|
|
393
396
|
export function toRelationshipStyle(props?: ast.RelationshipStyleProperty[]) {
|
|
394
397
|
const result = {} as {
|
|
395
|
-
color?: c4.
|
|
398
|
+
color?: c4.Color
|
|
396
399
|
line?: c4.RelationshipLineType
|
|
397
400
|
head?: c4.RelationshipArrowType
|
|
398
401
|
tail?: c4.RelationshipArrowType
|
|
@@ -402,7 +405,10 @@ export function toRelationshipStyle(props?: ast.RelationshipStyleProperty[]) {
|
|
|
402
405
|
}
|
|
403
406
|
for (const prop of props) {
|
|
404
407
|
if (ast.isColorProperty(prop)) {
|
|
405
|
-
|
|
408
|
+
const color = toColor(prop)
|
|
409
|
+
if (isTruthy(color)) {
|
|
410
|
+
result.color = color
|
|
411
|
+
}
|
|
406
412
|
continue
|
|
407
413
|
}
|
|
408
414
|
if (ast.isLineProperty(prop)) {
|
|
@@ -442,6 +448,10 @@ export function toRelationshipStyleExcludeDefaults(
|
|
|
442
448
|
}
|
|
443
449
|
}
|
|
444
450
|
|
|
451
|
+
export function toColor(astNode: ast.ColorProperty): c4.Color | undefined {
|
|
452
|
+
return astNode?.themeColor ?? (astNode?.customColor?.$refText as (c4.HexColorLiteral | undefined))
|
|
453
|
+
}
|
|
454
|
+
|
|
445
455
|
export function toAutoLayout(
|
|
446
456
|
direction: ast.ViewLayoutDirection
|
|
447
457
|
): c4.ViewRuleAutoLayout['autoLayout'] {
|
package/src/browser.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { startLanguageServer as startLanguim } from 'langium/lsp'
|
|
2
2
|
import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'
|
|
3
|
-
import { logToLspConnection } from './logger'
|
|
4
3
|
import { createLanguageServices } from './module'
|
|
5
4
|
|
|
6
5
|
// This is an example copied as is from here:
|
|
@@ -22,8 +21,6 @@ export function startLanguageServer() {
|
|
|
22
21
|
// Start the language server with the shared services
|
|
23
22
|
startLanguim(services.shared)
|
|
24
23
|
|
|
25
|
-
logToLspConnection(connection)
|
|
26
|
-
|
|
27
24
|
return {
|
|
28
25
|
...services,
|
|
29
26
|
connection,
|
package/src/elementRef.ts
CHANGED
package/src/generated/ast.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const LikeC4Terminals = {
|
|
|
24
24
|
Percent: /\b\d+%/,
|
|
25
25
|
String: /"[^"]*"|'[^']*'/,
|
|
26
26
|
IdTerminal: /[_]*[a-zA-Z][-\w]*/,
|
|
27
|
+
Hex: /[a-zA-Z0-9]+/,
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | 'odot' | 'onormal' | 'open' | 'vee';
|
|
@@ -38,6 +39,18 @@ export function isBorderStyleValue(item: unknown): item is BorderStyleValue {
|
|
|
38
39
|
return isLineOptions(item) || item === 'none';
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
export type CustomColorId = 'element' | 'model' | ArrowType | ElementShape | LineOptions | string;
|
|
43
|
+
|
|
44
|
+
export function isCustomColorId(item: unknown): item is CustomColorId {
|
|
45
|
+
return isElementShape(item) || isArrowType(item) || isLineOptions(item) || item === 'element' || item === 'model' || (typeof item === 'string' && (/[_]*[a-zA-Z][-\w]*/.test(item)));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type CustomColorValue = string;
|
|
49
|
+
|
|
50
|
+
export function isCustomColorValue(item: unknown): item is CustomColorValue {
|
|
51
|
+
return typeof item === 'string';
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
export type DotId = string;
|
|
42
55
|
|
|
43
56
|
export function isDotId(item: unknown): item is DotId {
|
|
@@ -321,8 +334,9 @@ export function isBorderProperty(item: unknown): item is BorderProperty {
|
|
|
321
334
|
export interface ColorProperty extends AstNode {
|
|
322
335
|
readonly $container: CustomElementProperties | CustomRelationProperties | ElementStyleProperty | RelationStyleProperty | SpecificationRelationshipKind | ViewRuleStyle;
|
|
323
336
|
readonly $type: 'ColorProperty';
|
|
337
|
+
customColor?: Reference<CustomColor>;
|
|
324
338
|
key: 'color';
|
|
325
|
-
|
|
339
|
+
themeColor?: ThemeColor;
|
|
326
340
|
}
|
|
327
341
|
|
|
328
342
|
export const ColorProperty = 'ColorProperty';
|
|
@@ -331,6 +345,18 @@ export function isColorProperty(item: unknown): item is ColorProperty {
|
|
|
331
345
|
return reflection.isInstance(item, ColorProperty);
|
|
332
346
|
}
|
|
333
347
|
|
|
348
|
+
export interface CustomColor extends AstNode {
|
|
349
|
+
readonly $container: SpecificationColor;
|
|
350
|
+
readonly $type: 'CustomColor';
|
|
351
|
+
name: CustomColorId;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export const CustomColor = 'CustomColor';
|
|
355
|
+
|
|
356
|
+
export function isCustomColor(item: unknown): item is CustomColor {
|
|
357
|
+
return reflection.isInstance(item, CustomColor);
|
|
358
|
+
}
|
|
359
|
+
|
|
334
360
|
export interface CustomElementProperties extends AstNode {
|
|
335
361
|
readonly $container: ElementPredicateWith;
|
|
336
362
|
readonly $type: 'CustomElementProperties';
|
|
@@ -1038,6 +1064,19 @@ export function isShapeProperty(item: unknown): item is ShapeProperty {
|
|
|
1038
1064
|
return reflection.isInstance(item, ShapeProperty);
|
|
1039
1065
|
}
|
|
1040
1066
|
|
|
1067
|
+
export interface SpecificationColor extends AstNode {
|
|
1068
|
+
readonly $container: SpecificationRule;
|
|
1069
|
+
readonly $type: 'SpecificationColor';
|
|
1070
|
+
color: CustomColorValue;
|
|
1071
|
+
name: CustomColor;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
export const SpecificationColor = 'SpecificationColor';
|
|
1075
|
+
|
|
1076
|
+
export function isSpecificationColor(item: unknown): item is SpecificationColor {
|
|
1077
|
+
return reflection.isInstance(item, SpecificationColor);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1041
1080
|
export interface SpecificationElementKind extends AstNode {
|
|
1042
1081
|
readonly $container: SpecificationRule;
|
|
1043
1082
|
readonly $type: 'SpecificationElementKind';
|
|
@@ -1093,6 +1132,7 @@ export function isSpecificationRelationshipStringProperty(item: unknown): item i
|
|
|
1093
1132
|
export interface SpecificationRule extends AstNode {
|
|
1094
1133
|
readonly $container: LikeC4Grammar;
|
|
1095
1134
|
readonly $type: 'SpecificationRule';
|
|
1135
|
+
colors: Array<SpecificationColor>;
|
|
1096
1136
|
elements: Array<SpecificationElementKind>;
|
|
1097
1137
|
name: 'specification';
|
|
1098
1138
|
relationships: Array<SpecificationRelationshipKind>;
|
|
@@ -1302,6 +1342,7 @@ export type LikeC4AstType = {
|
|
|
1302
1342
|
ArrowProperty: ArrowProperty
|
|
1303
1343
|
BorderProperty: BorderProperty
|
|
1304
1344
|
ColorProperty: ColorProperty
|
|
1345
|
+
CustomColor: CustomColor
|
|
1305
1346
|
CustomElementProperties: CustomElementProperties
|
|
1306
1347
|
CustomRelationProperties: CustomRelationProperties
|
|
1307
1348
|
DirectedRelationExpression: DirectedRelationExpression
|
|
@@ -1369,6 +1410,7 @@ export type LikeC4AstType = {
|
|
|
1369
1410
|
RelationshipKind: RelationshipKind
|
|
1370
1411
|
RelationshipStyleProperty: RelationshipStyleProperty
|
|
1371
1412
|
ShapeProperty: ShapeProperty
|
|
1413
|
+
SpecificationColor: SpecificationColor
|
|
1372
1414
|
SpecificationElementKind: SpecificationElementKind
|
|
1373
1415
|
SpecificationElementStringProperty: SpecificationElementStringProperty
|
|
1374
1416
|
SpecificationRelationshipKind: SpecificationRelationshipKind
|
|
@@ -1406,7 +1448,7 @@ export type LikeC4AstType = {
|
|
|
1406
1448
|
export class LikeC4AstReflection extends AbstractAstReflection {
|
|
1407
1449
|
|
|
1408
1450
|
getAllTypes(): string[] {
|
|
1409
|
-
return [ArrowProperty, BorderProperty, ColorProperty, CustomElementProperties, CustomRelationProperties, DirectedRelationExpression, DynamicView, DynamicViewBody, DynamicViewIncludePredicate, DynamicViewPredicateIterator, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementDescedantsExpression, ElementExpression, ElementExpressionsIterator, ElementKind, ElementKindExpression, ElementPredicate, ElementPredicateOrWhere, ElementPredicateWhere, ElementPredicateWith, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExcludePredicate, ExpandElementExpression, ExtendElement, ExtendElementBody, FqnElementRef, IconProperty, InOutRelationExpression, IncludePredicate, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelViews, NavigateToProperty, NotationProperty, OpacityProperty, OutgoingRelationExpression, Predicate, Predicates, Relation, RelationBody, RelationExpression, RelationPredicate, RelationPredicateOrWhere, RelationPredicateWhere, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRulePredicate, ViewRuleStyle, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationTag, WhereTagEqual, WildcardExpression];
|
|
1451
|
+
return [ArrowProperty, BorderProperty, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DirectedRelationExpression, DynamicView, DynamicViewBody, DynamicViewIncludePredicate, DynamicViewPredicateIterator, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementDescedantsExpression, ElementExpression, ElementExpressionsIterator, ElementKind, ElementKindExpression, ElementPredicate, ElementPredicateOrWhere, ElementPredicateWhere, ElementPredicateWith, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExcludePredicate, ExpandElementExpression, ExtendElement, ExtendElementBody, FqnElementRef, IconProperty, InOutRelationExpression, IncludePredicate, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelViews, NavigateToProperty, NotationProperty, OpacityProperty, OutgoingRelationExpression, Predicate, Predicates, Relation, RelationBody, RelationExpression, RelationPredicate, RelationPredicateOrWhere, RelationPredicateWhere, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationColor, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRulePredicate, ViewRuleStyle, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationTag, WhereTagEqual, WildcardExpression];
|
|
1410
1452
|
}
|
|
1411
1453
|
|
|
1412
1454
|
protected override computeIsSubtype(subtype: string, supertype: string): boolean {
|
|
@@ -1544,6 +1586,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
1544
1586
|
getReferenceType(refInfo: ReferenceInfo): string {
|
|
1545
1587
|
const referenceId = `${refInfo.container.$type}:${refInfo.property}`;
|
|
1546
1588
|
switch (referenceId) {
|
|
1589
|
+
case 'ColorProperty:customColor': {
|
|
1590
|
+
return CustomColor;
|
|
1591
|
+
}
|
|
1547
1592
|
case 'DynamicViewStep:kind':
|
|
1548
1593
|
case 'OutgoingRelationExpression:kind':
|
|
1549
1594
|
case 'Relation:kind':
|
|
@@ -1604,8 +1649,17 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
1604
1649
|
return {
|
|
1605
1650
|
name: ColorProperty,
|
|
1606
1651
|
properties: [
|
|
1652
|
+
{ name: 'customColor' },
|
|
1607
1653
|
{ name: 'key' },
|
|
1608
|
-
{ name: '
|
|
1654
|
+
{ name: 'themeColor' }
|
|
1655
|
+
]
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
case CustomColor: {
|
|
1659
|
+
return {
|
|
1660
|
+
name: CustomColor,
|
|
1661
|
+
properties: [
|
|
1662
|
+
{ name: 'name' }
|
|
1609
1663
|
]
|
|
1610
1664
|
};
|
|
1611
1665
|
}
|
|
@@ -2101,6 +2155,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
2101
2155
|
]
|
|
2102
2156
|
};
|
|
2103
2157
|
}
|
|
2158
|
+
case SpecificationColor: {
|
|
2159
|
+
return {
|
|
2160
|
+
name: SpecificationColor,
|
|
2161
|
+
properties: [
|
|
2162
|
+
{ name: 'color' },
|
|
2163
|
+
{ name: 'name' }
|
|
2164
|
+
]
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2104
2167
|
case SpecificationElementKind: {
|
|
2105
2168
|
return {
|
|
2106
2169
|
name: SpecificationElementKind,
|
|
@@ -2141,6 +2204,7 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
2141
2204
|
return {
|
|
2142
2205
|
name: SpecificationRule,
|
|
2143
2206
|
properties: [
|
|
2207
|
+
{ name: 'colors', defaultValue: [] },
|
|
2144
2208
|
{ name: 'elements', defaultValue: [] },
|
|
2145
2209
|
{ name: 'name' },
|
|
2146
2210
|
{ name: 'relationships', defaultValue: [] },
|