@likec4/language-server 1.11.0 → 1.12.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.
Files changed (37) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.d.cts +2 -2
  3. package/dist/browser.d.mts +2 -2
  4. package/dist/browser.d.ts +2 -2
  5. package/dist/browser.mjs +2 -2
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +2 -2
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.mjs +2 -2
  11. package/dist/likec4lib.cjs +589 -0
  12. package/dist/likec4lib.mjs +589 -0
  13. package/dist/model-graph/index.cjs +1 -1
  14. package/dist/model-graph/index.mjs +1 -1
  15. package/dist/shared/{language-server.DJhoJBWh.cjs → language-server.3Bh0zvVS.cjs} +10 -2
  16. package/dist/shared/{language-server.Cyw-bCtc.d.ts → language-server.BCDM5gt9.d.ts} +6 -3
  17. package/dist/shared/{language-server.DGjTE7xL.d.mts → language-server.BN7V1vQA.d.mts} +6 -3
  18. package/dist/shared/language-server.BX2gtzo8.d.cts +1233 -0
  19. package/dist/shared/{language-server.CCOotWDz.mjs → language-server.BbMFBkE-.mjs} +80 -24
  20. package/dist/shared/language-server.BiN_phWO.d.mts +1233 -0
  21. package/dist/shared/{language-server.CbqwHp7Q.mjs → language-server.BxxqS4Id.mjs} +10 -2
  22. package/dist/shared/{language-server.C8lV6gDw.cjs → language-server.BzrAcTYK.cjs} +78 -22
  23. package/dist/shared/{language-server.Ol32Kygo.d.cts → language-server.DtLmc4Fz.d.cts} +6 -3
  24. package/dist/shared/language-server.ljop0PBQ.d.ts +1233 -0
  25. package/package.json +11 -11
  26. package/src/ast.ts +23 -9
  27. package/src/formatting/LikeC4Formatter.ts +19 -7
  28. package/src/generated/ast.ts +9 -4
  29. package/src/generated/grammar.ts +1 -1
  30. package/src/generated-lib/icons.ts +589 -0
  31. package/src/like-c4.langium +8 -4
  32. package/src/lsp/CompletionProvider.ts +48 -1
  33. package/src/model/model-parser.ts +2 -6
  34. package/src/model-graph/compute-view/compute.ts +5 -1
  35. package/src/model-graph/dynamic-view/compute.ts +5 -1
  36. package/src/test/testServices.ts +1 -1
  37. package/src/view-utils/manual-layout.ts +5 -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.11.0",
4
+ "version": "1.12.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -112,8 +112,8 @@
112
112
  },
113
113
  "dependencies": {
114
114
  "@dagrejs/graphlib": "^2.2.4",
115
- "@likec4/core": "1.11.0",
116
- "@likec4/log": "1.11.0",
115
+ "@likec4/core": "1.12.0",
116
+ "@likec4/log": "1.12.0",
117
117
  "@msgpack/msgpack": "^3.0.0-beta2",
118
118
  "@smithy/util-base64": "^3.0.0",
119
119
  "fast-equals": "^5.0.1",
@@ -133,20 +133,20 @@
133
133
  "vscode-uri": "3.0.8"
134
134
  },
135
135
  "devDependencies": {
136
- "@likec4/icons": "1.11.0",
137
- "@likec4/tsconfig": "1.11.0",
138
- "@types/node": "^20.16.1",
136
+ "@likec4/icons": "1.12.0",
137
+ "@likec4/tsconfig": "1.12.0",
138
+ "@types/node": "^20.16.5",
139
139
  "@types/object-hash": "^3.0.6",
140
140
  "@types/string-hash": "^1.1.3",
141
- "@vitest/coverage-v8": "^2.1.1",
141
+ "@vitest/coverage-v8": "^2.1.2",
142
142
  "execa": "^9.3.1",
143
143
  "langium-cli": "3.2.0",
144
144
  "npm-run-all2": "^6.2.2",
145
145
  "tsx": "~4.9.3",
146
- "turbo": "^2.1.1",
146
+ "turbo": "^2.1.2",
147
147
  "typescript": "^5.6.2",
148
- "unbuild": "^3.0.0-rc.7",
149
- "vitest": "^2.1.1"
148
+ "unbuild": "^3.0.0-rc.8",
149
+ "vitest": "^2.1.2"
150
150
  },
151
- "packageManager": "yarn@4.4.1"
151
+ "packageManager": "yarn@4.5.0"
152
152
  }
package/src/ast.ts CHANGED
@@ -455,27 +455,41 @@ export function toColor(astNode: ast.ColorProperty): c4.Color | undefined {
455
455
  }
456
456
 
457
457
  export function toAutoLayout(
458
- direction: ast.ViewLayoutDirection
459
- ): c4.ViewRuleAutoLayout['autoLayout'] {
460
- switch (direction) {
458
+ rule: ast.ViewRuleAutoLayout
459
+ ): c4.ViewRuleAutoLayout {
460
+ const rankSep = rule.rankSep
461
+ const nodeSep = rule.nodeSep
462
+
463
+ let direction: c4.ViewRuleAutoLayout['direction'];
464
+ switch (rule.direction) {
461
465
  case 'TopBottom': {
462
- return 'TB'
466
+ direction = 'TB'
467
+ break
463
468
  }
464
469
  case 'BottomTop': {
465
- return 'BT'
470
+ direction = 'BT'
471
+ break
466
472
  }
467
473
  case 'LeftRight': {
468
- return 'LR'
474
+ direction = 'LR'
475
+ break
469
476
  }
470
477
  case 'RightLeft': {
471
- return 'RL'
478
+ direction = 'RL'
479
+ break
472
480
  }
473
481
  default:
474
- nonexhaustive(direction)
482
+ nonexhaustive(rule.direction)
483
+ }
484
+
485
+ return {
486
+ direction,
487
+ ...(nodeSep && { nodeSep }),
488
+ ...(rankSep && { rankSep })
475
489
  }
476
490
  }
477
491
 
478
- export function toAstViewLayoutDirection(c4: c4.ViewRuleAutoLayout['autoLayout']): ast.ViewLayoutDirection {
492
+ export function toAstViewLayoutDirection(c4: c4.ViewRuleAutoLayout['direction']): ast.ViewLayoutDirection {
479
493
  switch (c4) {
480
494
  case 'TB': {
481
495
  return 'TopBottom'
@@ -56,10 +56,18 @@ export class LikeC4Formatter extends AbstractFormatter {
56
56
  })
57
57
 
58
58
  this.on(node, ast.isDynamicViewStep, (n, f) => {
59
- f.properties('source').append(FormattingOptions.oneSpace)
60
- f.keywords(']->').prepend(FormattingOptions.noSpace)
61
- f.keywords('-[').append(FormattingOptions.noSpace)
62
- f.properties('target', 'title').prepend(FormattingOptions.oneSpace)
59
+ f.keywords('->', '<-').surround(FormattingOptions.oneSpace)
60
+
61
+ const kind = f.property('kind')
62
+ kind.nodes[0]?.text.startsWith('.') && kind.surround(FormattingOptions.oneSpace)
63
+ f.keywords(']->')
64
+ .prepend(FormattingOptions.noSpace)
65
+ .append(FormattingOptions.oneSpace)
66
+ f.keywords('-[')
67
+ .prepend(FormattingOptions.oneSpace)
68
+ .append(FormattingOptions.noSpace)
69
+
70
+ f.properties('title').prepend(FormattingOptions.oneSpace)
63
71
  })
64
72
 
65
73
  this.on(node, ast.isDirectedRelationExpression)
@@ -110,6 +118,7 @@ export class LikeC4Formatter extends AbstractFormatter {
110
118
  || ast.isCustomElementProperties(node)
111
119
  || ast.isCustomRelationProperties(node)
112
120
  || ast.isElementStyleProperty(node)
121
+ || ast.isDynamicViewParallelSteps(node)
113
122
  ) {
114
123
  const formatter = this.getNodeFormatter(node)
115
124
  const openBrace = formatter.keywords('{')
@@ -216,8 +225,11 @@ export class LikeC4Formatter extends AbstractFormatter {
216
225
  }
217
226
 
218
227
  protected formatAutolayoutProperty(node: AstNode) {
219
- this.on(node, ast.isViewRuleAutoLayout)
220
- ?.keyword('autoLayout').append(FormattingOptions.oneSpace)
228
+ this.on(node, ast.isViewRuleAutoLayout, (n, f) => {
229
+ f.keyword('autoLayout').append(FormattingOptions.oneSpace)
230
+ f.property('rankSep').prepend(FormattingOptions.oneSpace)
231
+ f.property('nodeSep').prepend(FormattingOptions.oneSpace)
232
+ })
221
233
  }
222
234
 
223
235
  protected formatMetadataProperty(node: AstNode) {
@@ -287,7 +299,7 @@ export class LikeC4Formatter extends AbstractFormatter {
287
299
  this.on(node, ast.isViewRuleStyle)
288
300
  ?.keyword('style').append(FormattingOptions.oneSpace)
289
301
 
290
- this.on(node, ast.isElementExpressionsIterator)
302
+ this.on(node, ast.isElementExpressionsIterator)
291
303
  ?.keyword(',')
292
304
  .prepend(FormattingOptions.noSpace)
293
305
  .append(FormattingOptions.oneSpace)
@@ -12,7 +12,7 @@ export const LikeC4Terminals = {
12
12
  LINE_COMMENT: /\/\/[^\n\r]*/,
13
13
  WS: /[\t ]+/,
14
14
  NL: /[\r\n]+/,
15
- LIB_ICON: /(aws|gcp|tech):[-\w]*/,
15
+ LIB_ICON: /(aws|azure|gcp|tech):[-\w]*/,
16
16
  URI_WITH_SCHEMA: /\w+:\/\/\S+/,
17
17
  URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
18
18
  DotUnderscore: /\b\._/,
@@ -25,7 +25,8 @@ export const LikeC4Terminals = {
25
25
  Percent: /\b\d+%/,
26
26
  String: /"[^"]*"|'[^']*'/,
27
27
  IdTerminal: /[_]*[a-zA-Z][-\w]*/,
28
- Hex: /[a-zA-Z0-9]+/,
28
+ Number: /\b\d+\b/,
29
+ Hex: /\b[a-zA-Z0-9]+\b/,
29
30
  };
30
31
 
31
32
  export type LikeC4TerminalNames = keyof typeof LikeC4Terminals;
@@ -205,7 +206,7 @@ export function isElementShape(item: unknown): item is ElementShape {
205
206
  export type IconId = string;
206
207
 
207
208
  export function isIconId(item: unknown): item is IconId {
208
- return (typeof item === 'string' && (/(aws|gcp|tech):[-\w]*/.test(item)));
209
+ return (typeof item === 'string' && (/(aws|azure|gcp|tech):[-\w]*/.test(item)));
209
210
  }
210
211
 
211
212
  export type Id = 'element' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
@@ -1347,6 +1348,8 @@ export interface ViewRuleAutoLayout extends AstNode {
1347
1348
  readonly $container: DynamicViewBody | ElementViewBody;
1348
1349
  readonly $type: 'ViewRuleAutoLayout';
1349
1350
  direction: ViewLayoutDirection;
1351
+ nodeSep?: number;
1352
+ rankSep?: number;
1350
1353
  }
1351
1354
 
1352
1355
  export const ViewRuleAutoLayout = 'ViewRuleAutoLayout';
@@ -2441,7 +2444,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2441
2444
  return {
2442
2445
  name: ViewRuleAutoLayout,
2443
2446
  properties: [
2444
- { name: 'direction' }
2447
+ { name: 'direction' },
2448
+ { name: 'nodeSep' },
2449
+ { name: 'rankSep' }
2445
2450
  ]
2446
2451
  };
2447
2452
  }