@likec4/language-server 1.11.0 → 1.12.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/dist/browser.cjs +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/likec4lib.cjs +589 -0
- package/dist/likec4lib.mjs +589 -0
- package/dist/model-graph/index.cjs +1 -1
- package/dist/model-graph/index.mjs +1 -1
- package/dist/shared/{language-server.DJhoJBWh.cjs → language-server.3Bh0zvVS.cjs} +10 -2
- package/dist/shared/{language-server.Cyw-bCtc.d.ts → language-server.B8Ce0R_D.d.ts} +5 -2
- package/dist/shared/language-server.BCDM5gt9.d.ts +1233 -0
- package/dist/shared/{language-server.C8lV6gDw.cjs → language-server.BH0brgLf.cjs} +98 -34
- package/dist/shared/language-server.BN7V1vQA.d.mts +1233 -0
- package/dist/shared/{language-server.CCOotWDz.mjs → language-server.BYjS7OIz.mjs} +100 -36
- package/dist/shared/{language-server.CbqwHp7Q.mjs → language-server.BxxqS4Id.mjs} +10 -2
- package/dist/shared/{language-server.DGjTE7xL.d.mts → language-server.CzkWpuWT.d.mts} +5 -2
- package/dist/shared/{language-server.Ol32Kygo.d.cts → language-server.DJAHXekh.d.cts} +5 -2
- package/dist/shared/language-server.DtLmc4Fz.d.cts +1233 -0
- package/package.json +11 -11
- package/src/ast.ts +23 -9
- package/src/formatting/LikeC4Formatter.ts +29 -12
- package/src/generated/ast.ts +9 -4
- package/src/generated/grammar.ts +1 -1
- package/src/generated-lib/icons.ts +589 -0
- package/src/like-c4.langium +8 -4
- package/src/lsp/CompletionProvider.ts +48 -1
- package/src/model/model-parser.ts +2 -6
- package/src/model-change/changeViewLayout.ts +15 -9
- package/src/model-graph/compute-view/compute.ts +5 -1
- package/src/model-graph/dynamic-view/compute.ts +5 -1
- package/src/test/testServices.ts +1 -1
- 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.
|
|
4
|
+
"version": "1.12.1",
|
|
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.
|
|
116
|
-
"@likec4/log": "1.
|
|
115
|
+
"@likec4/core": "1.12.1",
|
|
116
|
+
"@likec4/log": "1.12.1",
|
|
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.
|
|
137
|
-
"@likec4/tsconfig": "1.
|
|
138
|
-
"@types/node": "^20.16.
|
|
136
|
+
"@likec4/icons": "1.12.1",
|
|
137
|
+
"@likec4/tsconfig": "1.12.1",
|
|
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.
|
|
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.
|
|
146
|
+
"turbo": "^2.1.3",
|
|
147
147
|
"typescript": "^5.6.2",
|
|
148
|
-
"unbuild": "^3.0.0-rc.
|
|
149
|
-
"vitest": "^2.1.
|
|
148
|
+
"unbuild": "^3.0.0-rc.11",
|
|
149
|
+
"vitest": "^2.1.2"
|
|
150
150
|
},
|
|
151
|
-
"packageManager": "yarn@4.
|
|
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
|
-
|
|
459
|
-
): c4.ViewRuleAutoLayout
|
|
460
|
-
|
|
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
|
-
|
|
466
|
+
direction = 'TB'
|
|
467
|
+
break
|
|
463
468
|
}
|
|
464
469
|
case 'BottomTop': {
|
|
465
|
-
|
|
470
|
+
direction = 'BT'
|
|
471
|
+
break
|
|
466
472
|
}
|
|
467
473
|
case 'LeftRight': {
|
|
468
|
-
|
|
474
|
+
direction = 'LR'
|
|
475
|
+
break
|
|
469
476
|
}
|
|
470
477
|
case 'RightLeft': {
|
|
471
|
-
|
|
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['
|
|
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.
|
|
60
|
-
|
|
61
|
-
f.
|
|
62
|
-
|
|
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('{')
|
|
@@ -170,7 +179,8 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
170
179
|
|| ast.isOpacityProperty(node)
|
|
171
180
|
) {
|
|
172
181
|
const formatter = this.getNodeFormatter(node)
|
|
173
|
-
formatter.
|
|
182
|
+
const colon = formatter.keyword(':')
|
|
183
|
+
const propertyName = formatter.keywords(
|
|
174
184
|
'title',
|
|
175
185
|
'description',
|
|
176
186
|
'technology',
|
|
@@ -184,11 +194,15 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
184
194
|
'border',
|
|
185
195
|
'opacity'
|
|
186
196
|
)
|
|
187
|
-
.append(FormattingOptions.oneSpace)
|
|
188
197
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
if (colon.nodes.length === 0) {
|
|
199
|
+
propertyName
|
|
200
|
+
.append(FormattingOptions.oneSpace)
|
|
201
|
+
} else {
|
|
202
|
+
colon
|
|
203
|
+
.prepend(FormattingOptions.noSpace)
|
|
204
|
+
.append(FormattingOptions.oneSpace)
|
|
205
|
+
}
|
|
192
206
|
|
|
193
207
|
formatter.keyword(';')
|
|
194
208
|
.prepend(FormattingOptions.noSpace)
|
|
@@ -216,8 +230,11 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
protected formatAutolayoutProperty(node: AstNode) {
|
|
219
|
-
this.on(node, ast.isViewRuleAutoLayout)
|
|
220
|
-
|
|
233
|
+
this.on(node, ast.isViewRuleAutoLayout, (n, f) => {
|
|
234
|
+
f.keyword('autoLayout').append(FormattingOptions.oneSpace)
|
|
235
|
+
f.property('rankSep').prepend(FormattingOptions.oneSpace)
|
|
236
|
+
f.property('nodeSep').prepend(FormattingOptions.oneSpace)
|
|
237
|
+
})
|
|
221
238
|
}
|
|
222
239
|
|
|
223
240
|
protected formatMetadataProperty(node: AstNode) {
|
|
@@ -287,7 +304,7 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
287
304
|
this.on(node, ast.isViewRuleStyle)
|
|
288
305
|
?.keyword('style').append(FormattingOptions.oneSpace)
|
|
289
306
|
|
|
290
|
-
|
|
307
|
+
this.on(node, ast.isElementExpressionsIterator)
|
|
291
308
|
?.keyword(',')
|
|
292
309
|
.prepend(FormattingOptions.noSpace)
|
|
293
310
|
.append(FormattingOptions.oneSpace)
|
package/src/generated/ast.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|