@likec4/language-server 1.7.4 → 1.8.1
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/contrib/likec4.tmLanguage.json +1 -1
- package/package.json +9 -9
- package/src/ast.ts +34 -12
- package/src/generated/ast.ts +215 -120
- package/src/generated/grammar.ts +1 -1
- package/src/like-c4.langium +63 -23
- package/src/lsp/SemanticTokenProvider.ts +2 -2
- package/src/model/model-builder.ts +30 -13
- package/src/model/model-parser.ts +92 -22
- package/src/model-graph/compute-view/compute.ts +27 -5
- package/src/model-graph/dynamic-view/compute.ts +11 -3
- package/src/model-graph/utils/applyCustomElementProperties.ts +4 -3
- package/src/model-graph/utils/applyViewRuleStyles.ts +3 -0
- package/src/model-graph/utils/buildElementNotations.ts +63 -0
- package/src/references/scope-computation.ts +5 -5
- package/src/references/scope-provider.ts +21 -9
- package/src/validation/_shared.ts +24 -0
- package/src/validation/dynamic-view-rule.ts +0 -6
- package/src/validation/element.ts +9 -9
- package/src/validation/index.ts +2 -1
- package/src/validation/property-checks.ts +1 -1
- package/src/validation/relation.ts +45 -39
- package/src/validation/specification.ts +15 -2
- package/src/validation/view.ts +7 -0
- package/src/view-utils/view-hash.ts +12 -18
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "keyword.control.likec4",
|
|
15
|
-
"match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|and|autoLayout|blue|border|browser|color|crow|cylinder|dashed|description|diamond|dot|dotted|dynamic|element|element\\.kind|element\\.tag|exclude|extend|extends|gray|green|head|icon|icons|include|indigo|is|
|
|
15
|
+
"match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|and|autoLayout|blue|border|browser|color|crow|cylinder|dashed|description|diamond|dot|dotted|dynamic|element|element\\.kind|element\\.tag|exclude|extend|extends|gray|green|head|icon|icons|include|indigo|is|kind|likec4lib|line|link|metadata|mobile|model|muted|navigateTo|none|normal|not|notation|odiamond|odot|of|onormal|opacity|open|or|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|title|vee|view|views|where|with)\\b"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "string.quoted.double.likec4",
|
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.8.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"test:watch": "vitest"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"@dagrejs/graphlib": "^2.2.
|
|
95
|
-
"@likec4/core": "1.
|
|
96
|
-
"@likec4/log": "1.
|
|
94
|
+
"@dagrejs/graphlib": "^2.2.4",
|
|
95
|
+
"@likec4/core": "1.8.1",
|
|
96
|
+
"@likec4/log": "1.8.1",
|
|
97
97
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
98
98
|
"@smithy/util-base64": "^3.0.0",
|
|
99
99
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"langium": "3.1.3",
|
|
104
104
|
"object-hash": "^3.0.0",
|
|
105
105
|
"p-debounce": "^4.0.0",
|
|
106
|
-
"remeda": "^2.
|
|
106
|
+
"remeda": "^2.11.0",
|
|
107
107
|
"string-hash": "^1.1.3",
|
|
108
108
|
"strip-indent": "^4.0.0",
|
|
109
109
|
"type-fest": "^4.21.0",
|
|
@@ -114,12 +114,12 @@
|
|
|
114
114
|
"vscode-uri": "3.0.8"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@likec4/icons": "1.
|
|
118
|
-
"@likec4/tsconfig": "1.
|
|
119
|
-
"@types/node": "^20.
|
|
117
|
+
"@likec4/icons": "1.8.1",
|
|
118
|
+
"@likec4/tsconfig": "1.8.1",
|
|
119
|
+
"@types/node": "^20.16.1",
|
|
120
120
|
"@types/object-hash": "^3.0.6",
|
|
121
121
|
"@types/string-hash": "^1.1.3",
|
|
122
|
-
"execa": "^9.3.
|
|
122
|
+
"execa": "^9.3.1",
|
|
123
123
|
"glob": "^11.0.0",
|
|
124
124
|
"langium-cli": "3.1.1",
|
|
125
125
|
"npm-run-all2": "^6.2.2",
|
package/src/ast.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@likec4/core'
|
|
9
9
|
import type { AstNode, AstNodeDescription, DiagnosticInfo, LangiumDocument, MultiMap } from 'langium'
|
|
10
10
|
import { DocumentState } from 'langium'
|
|
11
|
-
import { clamp, isNullish, isTruthy } from 'remeda'
|
|
11
|
+
import { clamp, isDefined, isNullish, isTruthy } from 'remeda'
|
|
12
12
|
import type { ConditionalPick, SetRequired, ValueOf } from 'type-fest'
|
|
13
13
|
import type { Diagnostic } from 'vscode-languageserver-types'
|
|
14
14
|
import { DiagnosticSeverity } from 'vscode-languageserver-types'
|
|
@@ -42,10 +42,16 @@ type ParsedElementStyle = {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface ParsedAstSpecification {
|
|
45
|
-
kinds: Record<c4.ElementKind,
|
|
45
|
+
kinds: Record<c4.ElementKind, {
|
|
46
|
+
technology?: string
|
|
47
|
+
notation?: string
|
|
48
|
+
style: ParsedElementStyle
|
|
49
|
+
}>
|
|
46
50
|
relationships: Record<
|
|
47
51
|
c4.RelationshipKind,
|
|
48
52
|
{
|
|
53
|
+
technology?: string
|
|
54
|
+
notation?: string
|
|
49
55
|
color?: c4.ThemeColor
|
|
50
56
|
line?: c4.RelationshipLineType
|
|
51
57
|
head?: c4.RelationshipArrowType
|
|
@@ -62,8 +68,9 @@ export interface ParsedAstElement {
|
|
|
62
68
|
description?: string
|
|
63
69
|
technology?: string
|
|
64
70
|
tags?: c4.NonEmptyArray<c4.Tag>
|
|
65
|
-
links?: c4.NonEmptyArray<
|
|
71
|
+
links?: c4.NonEmptyArray<ParsedLink>
|
|
66
72
|
style: ParsedElementStyle
|
|
73
|
+
metadata?: { [key: string]: string }
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
export interface ParsedAstRelation {
|
|
@@ -80,7 +87,8 @@ export interface ParsedAstRelation {
|
|
|
80
87
|
line?: c4.RelationshipLineType
|
|
81
88
|
head?: c4.RelationshipArrowType
|
|
82
89
|
tail?: c4.RelationshipArrowType
|
|
83
|
-
links?: c4.NonEmptyArray<
|
|
90
|
+
links?: c4.NonEmptyArray<ParsedLink>
|
|
91
|
+
metadata?: { [key: string]: string }
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
export interface ParsedAstElementView {
|
|
@@ -92,7 +100,7 @@ export interface ParsedAstElementView {
|
|
|
92
100
|
title: string | null
|
|
93
101
|
description: string | null
|
|
94
102
|
tags: c4.NonEmptyArray<c4.Tag> | null
|
|
95
|
-
links: c4.NonEmptyArray<
|
|
103
|
+
links: c4.NonEmptyArray<ParsedLink> | null
|
|
96
104
|
rules: c4.ViewRule[]
|
|
97
105
|
manualLayout?: c4.ViewManualLayout
|
|
98
106
|
}
|
|
@@ -104,7 +112,7 @@ export interface ParsedAstDynamicView {
|
|
|
104
112
|
title: string | null
|
|
105
113
|
description: string | null
|
|
106
114
|
tags: c4.NonEmptyArray<c4.Tag> | null
|
|
107
|
-
links: c4.NonEmptyArray<
|
|
115
|
+
links: c4.NonEmptyArray<ParsedLink> | null
|
|
108
116
|
steps: c4.DynamicViewStep[]
|
|
109
117
|
rules: Array<c4.DynamicViewRule>
|
|
110
118
|
manualLayout?: c4.ViewManualLayout
|
|
@@ -121,6 +129,11 @@ export const ViewOps = {
|
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
|
|
132
|
+
export interface ParsedLink {
|
|
133
|
+
title?: string
|
|
134
|
+
url: string
|
|
135
|
+
}
|
|
136
|
+
|
|
124
137
|
export const ElementOps = {
|
|
125
138
|
writeId(node: ast.Element, id: c4.Fqn | null) {
|
|
126
139
|
if (isNullish(id)) {
|
|
@@ -309,7 +322,7 @@ export function resolveRelationPoints(node: ast.Relation): {
|
|
|
309
322
|
if (!target) {
|
|
310
323
|
throw new RelationRefError('Invalid reference to target')
|
|
311
324
|
}
|
|
312
|
-
if (
|
|
325
|
+
if (isDefined(node.source)) {
|
|
313
326
|
const source = elementRef(node.source)
|
|
314
327
|
if (!source) {
|
|
315
328
|
throw new RelationRefError('Invalid reference to source')
|
|
@@ -319,6 +332,9 @@ export function resolveRelationPoints(node: ast.Relation): {
|
|
|
319
332
|
target
|
|
320
333
|
}
|
|
321
334
|
}
|
|
335
|
+
if (!ast.isElementBody(node.$container)) {
|
|
336
|
+
throw new RelationRefError('Invalid container for sourceless relation')
|
|
337
|
+
}
|
|
322
338
|
return {
|
|
323
339
|
source: node.$container.$container,
|
|
324
340
|
target
|
|
@@ -338,15 +354,21 @@ export function toElementStyle(props?: Array<ast.StyleProperty>) {
|
|
|
338
354
|
for (const prop of props) {
|
|
339
355
|
switch (true) {
|
|
340
356
|
case ast.isBorderProperty(prop): {
|
|
341
|
-
|
|
357
|
+
if (isTruthy(prop.value)) {
|
|
358
|
+
result.border = prop.value
|
|
359
|
+
}
|
|
342
360
|
break
|
|
343
361
|
}
|
|
344
362
|
case ast.isColorProperty(prop): {
|
|
345
|
-
|
|
363
|
+
if (isTruthy(prop.value)) {
|
|
364
|
+
result.color = prop.value
|
|
365
|
+
}
|
|
346
366
|
break
|
|
347
367
|
}
|
|
348
368
|
case ast.isShapeProperty(prop): {
|
|
349
|
-
|
|
369
|
+
if (isTruthy(prop.value)) {
|
|
370
|
+
result.shape = prop.value
|
|
371
|
+
}
|
|
350
372
|
break
|
|
351
373
|
}
|
|
352
374
|
case ast.isIconProperty(prop): {
|
|
@@ -368,7 +390,7 @@ export function toElementStyle(props?: Array<ast.StyleProperty>) {
|
|
|
368
390
|
return result
|
|
369
391
|
}
|
|
370
392
|
|
|
371
|
-
export function toRelationshipStyle(props?: ast.
|
|
393
|
+
export function toRelationshipStyle(props?: ast.RelationshipStyleProperty[]) {
|
|
372
394
|
const result = {} as {
|
|
373
395
|
color?: c4.ThemeColor
|
|
374
396
|
line?: c4.RelationshipLineType
|
|
@@ -411,7 +433,7 @@ export function toRelationshipStyle(props?: ast.SpecificationRelationshipKind['p
|
|
|
411
433
|
export function toRelationshipStyleExcludeDefaults(
|
|
412
434
|
props?: ast.SpecificationRelationshipKind['props']
|
|
413
435
|
) {
|
|
414
|
-
const { color, line, head, tail } = toRelationshipStyle(props)
|
|
436
|
+
const { color, line, head, tail } = toRelationshipStyle(props?.filter(ast.isRelationshipStyleProperty))
|
|
415
437
|
return {
|
|
416
438
|
...(color && color !== DefaultRelationshipColor ? { color } : {}),
|
|
417
439
|
...(line && line !== DefaultLineStyle ? { line } : {}),
|