@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.
@@ -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|it|kind|likec4lib|line|link|mobile|model|muted|navigateTo|none|normal|not|odiamond|odot|of|onormal|opacity|open|or|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|this|title|vee|view|views|where|with)\\b"
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.7.4",
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.3",
95
- "@likec4/core": "1.7.4",
96
- "@likec4/log": "1.7.4",
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.3.0",
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.7.4",
118
- "@likec4/tsconfig": "1.7.4",
119
- "@types/node": "^20.14.14",
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.0",
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, ParsedElementStyle>
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<string>
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<string>
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<string> | null
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<string> | null
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 (ast.isExplicitRelation(node)) {
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
- result.border = prop.value
357
+ if (isTruthy(prop.value)) {
358
+ result.border = prop.value
359
+ }
342
360
  break
343
361
  }
344
362
  case ast.isColorProperty(prop): {
345
- result.color = prop.value
363
+ if (isTruthy(prop.value)) {
364
+ result.color = prop.value
365
+ }
346
366
  break
347
367
  }
348
368
  case ast.isShapeProperty(prop): {
349
- result.shape = prop.value
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.SpecificationRelationshipKind['props']) {
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 } : {}),