@likec4/language-server 1.20.2 → 1.21.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/README.md +1 -1
- package/dist/ast.d.ts +16 -0
- package/dist/ast.js +42 -10
- package/dist/bundled.mjs +4230 -4096
- package/dist/formatting/LikeC4Formatter.js +6 -3
- package/dist/generated/ast.d.ts +76 -24
- package/dist/generated/ast.js +103 -25
- package/dist/generated/grammar.js +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +0 -4
- package/dist/lsp/CompletionProvider.js +2 -1
- package/dist/lsp/SemanticTokenProvider.js +50 -2
- package/dist/model/model-builder.js +57 -3
- package/dist/model/model-parser.d.ts +6 -0
- package/dist/model/model-parser.js +1 -0
- package/dist/model/parser/Base.js +11 -5
- package/dist/model/parser/DeploymentModelParser.d.ts +1 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +1 -0
- package/dist/model/parser/DeploymentViewParser.js +3 -0
- package/dist/model/parser/FqnRefParser.d.ts +1 -0
- package/dist/model/parser/FqnRefParser.js +10 -0
- package/dist/model/parser/GlobalsParser.d.ts +1 -0
- package/dist/model/parser/ModelParser.d.ts +2 -1
- package/dist/model/parser/ModelParser.js +26 -1
- package/dist/model/parser/PredicatesParser.js +19 -1
- package/dist/model/parser/ViewsParser.d.ts +1 -0
- package/dist/references/scope-provider.d.ts +1 -1
- package/dist/references/scope-provider.js +1 -1
- package/dist/test/testServices.d.ts +1 -0
- package/dist/test/testServices.js +8 -0
- package/dist/utils/elementRef.d.ts +3 -3
- package/dist/validation/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/ast.ts +55 -9
- package/src/formatting/LikeC4Formatter.ts +7 -1
- package/src/generated/ast.ts +200 -49
- package/src/generated/grammar.ts +1 -1
- package/src/like-c4.langium +45 -7
- package/src/logger.ts +3 -4
- package/src/lsp/CompletionProvider.ts +1 -0
- package/src/lsp/SemanticTokenProvider.ts +56 -1
- package/src/model/model-builder.ts +65 -6
- package/src/model/model-parser.ts +1 -0
- package/src/model/parser/Base.ts +11 -5
- package/src/model/parser/DeploymentViewParser.ts +3 -0
- package/src/model/parser/FqnRefParser.ts +11 -0
- package/src/model/parser/ModelParser.ts +30 -1
- package/src/model/parser/PredicatesParser.ts +19 -1
- package/src/references/scope-provider.ts +9 -9
- package/src/test/testServices.ts +18 -9
- package/src/utils/elementRef.ts +3 -3
package/src/ast.ts
CHANGED
|
@@ -43,6 +43,9 @@ type ParsedElementStyle = {
|
|
|
43
43
|
border?: c4.BorderStyle
|
|
44
44
|
opacity?: number
|
|
45
45
|
multiple?: boolean
|
|
46
|
+
size?: c4.ShapeSize
|
|
47
|
+
padding?: c4.SpacingSize
|
|
48
|
+
textSize?: c4.TextSize
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export interface ParsedAstSpecification {
|
|
@@ -85,6 +88,14 @@ export interface ParsedAstElement {
|
|
|
85
88
|
metadata?: { [key: string]: string }
|
|
86
89
|
}
|
|
87
90
|
|
|
91
|
+
export interface ParsedAstExtendElement {
|
|
92
|
+
id: c4.Fqn
|
|
93
|
+
astPath: string
|
|
94
|
+
tags?: c4.NonEmptyArray<c4.Tag>
|
|
95
|
+
links?: c4.NonEmptyArray<ParsedLink>
|
|
96
|
+
metadata?: { [key: string]: string }
|
|
97
|
+
}
|
|
98
|
+
|
|
88
99
|
export interface ParsedAstRelation {
|
|
89
100
|
id: c4.RelationId
|
|
90
101
|
astPath: string
|
|
@@ -202,6 +213,7 @@ export interface LikeC4DocumentProps {
|
|
|
202
213
|
diagnostics?: Array<LikeC4DocumentDiagnostic>
|
|
203
214
|
c4Specification?: ParsedAstSpecification
|
|
204
215
|
c4Elements?: ParsedAstElement[]
|
|
216
|
+
c4ExtendElements?: ParsedAstExtendElement[]
|
|
205
217
|
c4Relations?: ParsedAstRelation[]
|
|
206
218
|
c4Globals?: ParsedAstGlobals
|
|
207
219
|
c4Views?: ParsedAstView[]
|
|
@@ -234,6 +246,7 @@ export function isParsedLikeC4LangiumDocument(
|
|
|
234
246
|
&& doc.state == DocumentState.Validated
|
|
235
247
|
&& !!doc.c4Specification
|
|
236
248
|
&& !!doc.c4Elements
|
|
249
|
+
&& !!doc.c4ExtendElements
|
|
237
250
|
&& !!doc.c4Relations
|
|
238
251
|
&& !!doc.c4Views
|
|
239
252
|
&& !!doc.c4fqnIndex
|
|
@@ -251,15 +264,7 @@ export function* streamModel(doc: LikeC4LangiumDocument) {
|
|
|
251
264
|
relations.push(el)
|
|
252
265
|
continue
|
|
253
266
|
}
|
|
254
|
-
if (
|
|
255
|
-
if (el.body && el.body.elements.length > 0) {
|
|
256
|
-
for (const child of el.body.elements) {
|
|
257
|
-
traverseStack.push(child)
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
continue
|
|
261
|
-
}
|
|
262
|
-
if (el.body && el.body.elements.length > 0) {
|
|
267
|
+
if (el.body && el.body.elements && el.body.elements.length > 0) {
|
|
263
268
|
for (const child of el.body.elements) {
|
|
264
269
|
traverseStack.push(child)
|
|
265
270
|
}
|
|
@@ -324,6 +329,29 @@ export function parseAstOpacityProperty({ value }: ast.OpacityProperty): number
|
|
|
324
329
|
return isNaN(opacity) ? 100 : clamp(opacity, { min: 0, max: 100 })
|
|
325
330
|
}
|
|
326
331
|
|
|
332
|
+
export function parseAstSizeValue({ value }: { value: ast.SizeValue }): 'xs' | 'sm' | 'md' | 'lg' | 'xl' {
|
|
333
|
+
switch (value) {
|
|
334
|
+
case 'xs':
|
|
335
|
+
case 'sm':
|
|
336
|
+
case 'md':
|
|
337
|
+
case 'lg':
|
|
338
|
+
case 'xl':
|
|
339
|
+
return value
|
|
340
|
+
case 'xsmall':
|
|
341
|
+
return 'xs'
|
|
342
|
+
case 'small':
|
|
343
|
+
return 'sm'
|
|
344
|
+
case 'medium':
|
|
345
|
+
return 'md'
|
|
346
|
+
case 'large':
|
|
347
|
+
return 'lg'
|
|
348
|
+
case 'xlarge':
|
|
349
|
+
return 'xl'
|
|
350
|
+
default:
|
|
351
|
+
nonexhaustive(value)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
327
355
|
export function toElementStyle(props: Array<ast.StyleProperty> | undefined, isValid: IsValidFn) {
|
|
328
356
|
const result = {} as ParsedElementStyle
|
|
329
357
|
if (!props || props.length === 0) {
|
|
@@ -368,6 +396,24 @@ export function toElementStyle(props: Array<ast.StyleProperty> | undefined, isVa
|
|
|
368
396
|
result.multiple = isBoolean(prop.value) ? prop.value : false
|
|
369
397
|
break
|
|
370
398
|
}
|
|
399
|
+
case ast.isShapeSizeProperty(prop): {
|
|
400
|
+
if (isTruthy(prop.value)) {
|
|
401
|
+
result.size = parseAstSizeValue(prop)
|
|
402
|
+
}
|
|
403
|
+
break
|
|
404
|
+
}
|
|
405
|
+
case ast.isPaddingSizeProperty(prop): {
|
|
406
|
+
if (isTruthy(prop.value)) {
|
|
407
|
+
result.padding = parseAstSizeValue(prop)
|
|
408
|
+
}
|
|
409
|
+
break
|
|
410
|
+
}
|
|
411
|
+
case ast.isTextSizeProperty(prop): {
|
|
412
|
+
if (isTruthy(prop.value)) {
|
|
413
|
+
result.textSize = parseAstSizeValue(prop)
|
|
414
|
+
}
|
|
415
|
+
break
|
|
416
|
+
}
|
|
371
417
|
default:
|
|
372
418
|
nonexhaustive(prop)
|
|
373
419
|
}
|
|
@@ -241,6 +241,9 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
241
241
|
|| ast.isBorderProperty(node)
|
|
242
242
|
|| ast.isOpacityProperty(node)
|
|
243
243
|
|| ast.isMultipleProperty(node)
|
|
244
|
+
|| ast.isShapeSizeProperty(node)
|
|
245
|
+
|| ast.isPaddingSizeProperty(node)
|
|
246
|
+
|| ast.isTextSizeProperty(node)
|
|
244
247
|
) {
|
|
245
248
|
const formatter = this.getNodeFormatter(node)
|
|
246
249
|
const colon = formatter.keyword(':')
|
|
@@ -258,6 +261,9 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
258
261
|
'border',
|
|
259
262
|
'opacity',
|
|
260
263
|
'multiple',
|
|
264
|
+
'size',
|
|
265
|
+
'padding',
|
|
266
|
+
'textSize',
|
|
261
267
|
)
|
|
262
268
|
|
|
263
269
|
if (colon.nodes.length === 0) {
|
|
@@ -471,7 +477,7 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
471
477
|
protected formatWhereExpressionV2(node: AstNode) {
|
|
472
478
|
if (
|
|
473
479
|
ast.isRelationPredicateOrWhereV2(node)
|
|
474
|
-
|
|
480
|
+
|| ast.isElementPredicateOrWhereV2(node)
|
|
475
481
|
) {
|
|
476
482
|
const formatter = this.getNodeFormatter(node)
|
|
477
483
|
formatter.keyword('where').append(FormattingOptions.oneSpace)
|