@likec4/language-server 1.20.0 → 1.20.2

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 (53) hide show
  1. package/README.md +19 -0
  2. package/bin/likec4-language-server.mjs +5 -0
  3. package/dist/LikeC4FileSystem.js +9 -9
  4. package/dist/Rpc.d.ts +2 -4
  5. package/dist/Rpc.js +27 -36
  6. package/dist/ast.d.ts +1 -0
  7. package/dist/ast.js +5 -1
  8. package/dist/bundled.mjs +5924 -0
  9. package/dist/formatting/LikeC4Formatter.d.ts +9 -0
  10. package/dist/formatting/LikeC4Formatter.js +131 -14
  11. package/dist/generated/ast.d.ts +13 -2
  12. package/dist/generated/ast.js +18 -1
  13. package/dist/generated/grammar.js +1 -1
  14. package/dist/lsp/CompletionProvider.js +11 -3
  15. package/dist/model/deployments-index.d.ts +2 -1
  16. package/dist/model/deployments-index.js +3 -10
  17. package/dist/model/fqn-index.d.ts +2 -1
  18. package/dist/model/fqn-index.js +24 -17
  19. package/dist/model/model-builder.d.ts +2 -1
  20. package/dist/model/model-builder.js +32 -30
  21. package/dist/model/model-parser.d.ts +1 -1
  22. package/dist/model/model-parser.js +9 -6
  23. package/dist/model/parser/PredicatesParser.js +7 -1
  24. package/dist/utils/disposable.d.ts +8 -0
  25. package/dist/utils/disposable.js +25 -0
  26. package/dist/utils/index.d.ts +1 -0
  27. package/dist/utils/index.js +1 -0
  28. package/dist/validation/_shared.js +4 -1
  29. package/dist/validation/index.d.ts +2 -2
  30. package/dist/validation/index.js +4 -1
  31. package/dist/validation/specification.d.ts +1 -0
  32. package/dist/validation/specification.js +30 -0
  33. package/package.json +33 -27
  34. package/src/LikeC4FileSystem.ts +14 -13
  35. package/src/Rpc.ts +28 -38
  36. package/src/ast.ts +6 -1
  37. package/src/formatting/LikeC4Formatter.ts +198 -17
  38. package/src/generated/ast.ts +35 -2
  39. package/src/generated/grammar.ts +1 -1
  40. package/src/like-c4.langium +14 -3
  41. package/src/lsp/CompletionProvider.ts +27 -18
  42. package/src/model/deployments-index.ts +4 -17
  43. package/src/model/fqn-index.ts +26 -19
  44. package/src/model/model-builder.ts +32 -31
  45. package/src/model/model-parser.ts +14 -11
  46. package/src/model/parser/PredicatesParser.ts +30 -24
  47. package/src/utils/disposable.ts +30 -0
  48. package/src/utils/index.ts +1 -0
  49. package/src/validation/_shared.ts +5 -2
  50. package/src/validation/index.ts +6 -2
  51. package/src/validation/specification.ts +34 -0
  52. package/contrib/likec4.tmLanguage.json +0 -73
  53. package/dist/like-c4.langium +0 -852
@@ -1,852 +0,0 @@
1
- grammar LikeC4
2
-
3
- entry LikeC4Grammar:
4
- (
5
- specifications+=SpecificationRule |
6
- models+=Model |
7
- views+=ModelViews |
8
- globals+=Globals |
9
- deployments+=ModelDeployments |
10
- likec4lib+=LikeC4Lib
11
- )*
12
- ;
13
-
14
- // Lib -------------------------------------
15
- LikeC4Lib:
16
- 'likec4lib' '{'
17
- 'icons' '{'
18
- (icons+=LibIcon)+
19
- '}'
20
- '}';
21
-
22
- LibIcon: name=IconId;
23
-
24
- // Specification -------------------------------------
25
-
26
- ElementKind: name=Id;
27
- Tag: name=Id;
28
- RelationshipKind: name=Id;
29
- CustomColor: name=CustomColorId;
30
- DeploymentNodeKind: name=Id;
31
-
32
- SpecificationRule:
33
- name='specification' '{'
34
- (
35
- elements+=SpecificationElementKind |
36
- tags+=SpecificationTag |
37
- relationships+=SpecificationRelationshipKind |
38
- colors+=SpecificationColor |
39
- deploymentNodes+=SpecificationDeploymentNodeKind
40
- )*
41
- '}';
42
-
43
- SpecificationElementKind:
44
- 'element' kind=ElementKind ('{'
45
- props+=(
46
- SpecificationElementStringProperty |
47
- ElementStyleProperty
48
- )*
49
- '}')?;
50
-
51
- SpecificationElementStringProperty:
52
- key=('technology' | 'notation') ':'? value=String ';'?;
53
-
54
- SpecificationDeploymentNodeKind:
55
- 'deploymentNode' kind=DeploymentNodeKind ('{'
56
- props+=(
57
- SpecificationElementStringProperty |
58
- ElementStyleProperty
59
- )*
60
- '}')?;
61
-
62
- SpecificationTag:
63
- 'tag' tag=Tag;
64
-
65
- SpecificationColor:
66
- 'color' name=CustomColor color=CustomColorValue;
67
-
68
- SpecificationRelationshipKind:
69
- 'relationship' kind=RelationshipKind ('{'
70
- props+=(
71
- RelationshipStyleProperty |
72
- SpecificationRelationshipStringProperty
73
- )*
74
- '}')?
75
- ;
76
-
77
- SpecificationRelationshipStringProperty:
78
- key=('technology' | 'notation') ':'? value=String ';'?;
79
-
80
- // Model -------------------------------------
81
-
82
- Model:
83
- name='model' '{'
84
- elements+=(
85
- ExtendElement |
86
- Relation<true> |
87
- Element
88
- )*
89
- '}'
90
- ;
91
-
92
- Element:
93
- (
94
- kind=[ElementKind] name=Id |
95
- name=Id Eq kind=[ElementKind]
96
- )
97
- (props+=String // title
98
- (props+=String // description
99
- (props+=String // technology
100
- (props+=String)? // tags
101
- )?
102
- )?
103
- )?
104
- body=ElementBody?
105
- ;
106
-
107
- ElementBody: '{'
108
- tags=Tags?
109
- props+=ElementProperty*
110
- elements+=(
111
- Relation<false> |
112
- Element
113
- )*
114
- '}'
115
- ;
116
-
117
- ElementProperty:
118
- ElementStringProperty | ElementStyleProperty | LinkProperty | IconProperty | MetadataProperty;
119
-
120
- ElementStringProperty:
121
- key=('title' | 'technology' | 'description') ':'? value=String ';'?;
122
-
123
- ExtendElement:
124
- 'extend' element=FqnElementRef body=ExtendElementBody
125
- ;
126
-
127
- ExtendElementBody: '{'
128
- elements+=(
129
- Relation<true> |
130
- Element
131
- )*
132
- '}'
133
- ;
134
-
135
- //
136
- FqnElementRef:
137
- el=[Element:Id] ({infer FqnElementRef.parent=current} StickyDot el=[Element:Id])*;
138
-
139
- ElementRef:
140
- el=[Element:Id] ({infer ElementRef.parent=current} StickyDot el=[Element:Id])*;
141
-
142
- Tags:
143
- (values+=[Tag:TagId])+ ({infer Tags.prev=current} ',' (values+=[Tag:TagId])*)* ';'?
144
- ;
145
-
146
- Relation<isExplicit>:
147
- (<isExplicit> source=ElementRef | <!isExplicit> source=ElementRef?)
148
- (
149
- kind=[RelationshipKind:DotId] |
150
- '-[' kind=[RelationshipKind] ']->' |
151
- '->'
152
- )
153
- target=ElementRef
154
- (
155
- title=String
156
- technology=String?
157
- )?
158
- tags=Tags?
159
- body=RelationBody?
160
- ;
161
-
162
- RelationBody: '{'
163
- tags=Tags?
164
- props+=RelationProperty*
165
- '}'
166
- ;
167
-
168
- RelationProperty:
169
- RelationStringProperty |
170
- RelationNavigateToProperty |
171
- RelationStyleProperty |
172
- LinkProperty |
173
- MetadataProperty
174
- ;
175
-
176
- RelationStringProperty:
177
- key=('title' | 'technology' | 'description') ':'? value=String ';'?;
178
-
179
- RelationStyleProperty:
180
- key='style' '{'
181
- props+=RelationshipStyleProperty*
182
- '}'
183
- ;
184
-
185
- MetadataProperty:
186
- 'metadata' MetadataBody
187
- ;
188
-
189
- MetadataBody: '{'
190
- props+=(MetadataAttribute)*
191
- '}'
192
- ;
193
-
194
- MetadataAttribute:
195
- key=IdTerminal ':'? value=String ';'?
196
- ;
197
-
198
- // Views -------------------------------------
199
-
200
- ModelViews:
201
- name='views' '{' (
202
- views+=LikeC4ViewRule |
203
- styles+=ViewRuleStyleOrGlobalRef
204
- )*
205
- '}';
206
-
207
- type LikeC4View = ElementView | DynamicView | DeploymentView;
208
- LikeC4ViewRule returns LikeC4View:
209
- ElementView | DynamicView | DeploymentView;
210
-
211
- ElementView:
212
- 'view' name=Id? (
213
- 'extends' extends=ElementViewRef |
214
- 'of' viewOf=ElementRef
215
- )?
216
- body=ElementViewBody?
217
- ;
218
-
219
- DynamicView:
220
- 'dynamic' 'view' name=Id body=DynamicViewBody?
221
- ;
222
-
223
- ViewRef:
224
- view=[LikeC4View];
225
-
226
- ElementViewRef:
227
- view=[ElementView];
228
-
229
- DynamicViewRef:
230
- view=[DynamicView];
231
-
232
- ElementViewBody: '{'
233
- tags=Tags?
234
- props+=ViewProperty*
235
- rules+=ViewRule*
236
- '}'
237
- ;
238
-
239
- DynamicViewBody: '{'
240
- tags=Tags?
241
- props+=ViewProperty*
242
- (
243
- steps+=(DynamicViewParallelSteps | DynamicViewStep) |
244
- rules+=DynamicViewRule
245
- )*
246
- '}'
247
- ;
248
-
249
-
250
- type StringProperty =
251
- ElementStringProperty |
252
- ViewStringProperty |
253
- RelationStringProperty |
254
- MetadataAttribute |
255
- SpecificationElementStringProperty |
256
- SpecificationRelationshipStringProperty |
257
- NotationProperty |
258
- NotesProperty
259
- ;
260
-
261
- ViewProperty:
262
- ViewStringProperty | LinkProperty
263
- ;
264
-
265
- ViewStringProperty:
266
- key=('title' | 'description') ':'? value=String ';'?;
267
-
268
- ViewLayoutDirection returns string:
269
- 'TopBottom' | 'LeftRight' | 'BottomTop' | 'RightLeft';
270
-
271
- ViewRule:
272
- ViewRulePredicate |
273
- ViewRuleGlobalPredicateRef |
274
- ViewRuleGroup |
275
- ViewRuleStyleOrGlobalRef |
276
- ViewRuleAutoLayout
277
- ;
278
-
279
- ViewRuleGroup:
280
- 'group' title=String? '{'
281
- props+=(
282
- ColorProperty |
283
- BorderProperty |
284
- OpacityProperty
285
- )*
286
- groupRules+=(
287
- ViewRulePredicate |
288
- ViewRuleGroup
289
- )*
290
- '}';
291
-
292
- DynamicViewRule:
293
- DynamicViewIncludePredicate |
294
- DynamicViewGlobalPredicateRef |
295
- ViewRuleStyleOrGlobalRef |
296
- ViewRuleAutoLayout
297
- ;
298
-
299
- DynamicViewParallelSteps:
300
- ('parallel'|'par') '{'
301
- (steps+=DynamicViewStep)*
302
- '}'
303
- ;
304
-
305
- DynamicViewStep:
306
- source=ElementRef
307
- (isBackward?='<-' | '->' | '-[' kind=[RelationshipKind] ']->' | kind=[RelationshipKind:DotId] )
308
- target=ElementRef
309
- title=String?
310
- custom=CustomRelationProperties?
311
- ;
312
-
313
- ViewRulePredicate:
314
- {infer IncludePredicate} 'include' predicates=Predicates |
315
- {infer ExcludePredicate} 'exclude' predicates=Predicates
316
- ;
317
- Predicates:
318
- value=Predicate ({infer Predicates.prev=current} ',' value=Predicate?)*
319
- ;
320
-
321
- Predicate:
322
- RelationPredicate |
323
- ElementPredicate
324
- ;
325
-
326
- ViewRuleGlobalPredicateRef:
327
- 'global' 'predicate' predicate=[GlobalPredicateGroup];
328
-
329
- ElementPredicate:
330
- ElementPredicates;
331
-
332
- ElementPredicates infers ElementPredicate:
333
- ElementPredicateOrWhere ({infer ElementPredicateWith.subject=current} 'with' custom=CustomElementProperties?)?
334
- ;
335
-
336
- ElementPredicateOrWhere:
337
- ElementExpression ({infer ElementPredicateWhere.subject=current} 'where' where=WhereElementExpression?)?
338
- ;
339
-
340
- WhereElementExpression:
341
- WhereElementOr
342
- ;
343
- WhereElementOr infers WhereElementExpression:
344
- WhereElementAnd ({infer WhereBinaryExpression.left=current} operator='or' right=WhereElementAnd)*
345
- ;
346
- WhereElementAnd infers WhereElementExpression:
347
- WhereElementPrimary ({infer WhereBinaryExpression.left=current} operator='and' right=WhereElementPrimary)*
348
- ;
349
-
350
- WhereElementPrimary infers WhereElementExpression:
351
- '(' WhereElementExpression ')' |
352
- WhereElementNegation |
353
- WhereElement
354
- ;
355
-
356
- WhereElementNegation:
357
- 'not' value=WhereElementExpression;
358
-
359
- WhereElement:
360
- {infer WhereElementTag} 'tag' EqOperator value=[Tag:TagId]? |
361
- {infer WhereElementKind} 'kind' EqOperator value=[ElementKind]?
362
- ;
363
-
364
- ElementExpression:
365
- ElementSelectorExpression |
366
- ElementDescedantsExpression
367
- ;
368
-
369
- ElementSelectorExpression infers ElementExpression:
370
- {infer WildcardExpression} isWildcard?='*' |
371
- {infer ElementTagExpression} 'element.tag' IsEqual tag=[Tag:TagId]? |
372
- {infer ElementKindExpression} 'element.kind' IsEqual kind=[ElementKind]?
373
- ;
374
-
375
- ElementDescedantsExpression infers ElementExpression:
376
- ElementRef (
377
- {infer ExpandElementExpression.expand=current} DotUnderscore |
378
- {infer ElementDescedantsExpression.parent=current} suffix=DotWildcard
379
- )?
380
- ;
381
-
382
- RelationPredicate:
383
- RelationPredicates
384
- ;
385
-
386
- RelationPredicates infers RelationPredicate:
387
- RelationPredicateOrWhere ({infer RelationPredicateWith.subject=current} 'with' custom=CustomRelationProperties?)?
388
- ;
389
-
390
- RelationPredicateOrWhere:
391
- RelationExpression ({infer RelationPredicateWhere.subject=current} 'where' where=WhereRelationExpression?)?
392
- ;
393
-
394
- WhereRelationExpression:
395
- WhereRelationOr
396
- ;
397
-
398
- WhereRelationOr infers WhereRelationExpression:
399
- WhereRelationAnd ({infer WhereBinaryExpression.left=current} operator='or' right=WhereRelationAnd)*
400
- ;
401
- WhereRelationAnd infers WhereRelationExpression:
402
- WhereRelationPrimary ({infer WhereBinaryExpression.left=current} operator='and' right=WhereRelationPrimary)*
403
- ;
404
-
405
- WhereRelationPrimary infers WhereRelationExpression:
406
- '(' WhereRelationExpression ')' |
407
- WhereRelationNegation |
408
- WhereRelation
409
- ;
410
-
411
- WhereRelationNegation:
412
- 'not' value=WhereRelationExpression;
413
-
414
- WhereRelation:
415
- {infer WhereRelationTag} 'tag' EqOperator value=[Tag:TagId]? |
416
- {infer WhereRelationKind} 'kind' EqOperator value=[RelationshipKind:Id]? |
417
- {infer WhereRelationParticipantTag} participant=Participant StickyDot 'tag' EqOperator value=[Tag:TagId]? |
418
- {infer WhereRelationParticipantKind} participant=Participant StickyDot 'kind' EqOperator value=[DeploymentNodeOrElementKind:Id]?
419
- ;
420
- type DeploymentNodeOrElementKind = ElementKind | DeploymentNodeKind
421
- type WhereTagEqual = WhereElementTag | WhereRelationTag | WhereRelationParticipantTag;
422
- type WhereKindEqual = WhereElementKind | WhereRelationKind | WhereRelationParticipantKind;
423
-
424
- type WhereExpression = WhereElementExpression | WhereRelationExpression;
425
-
426
- RelationExpression:
427
- InOutRelationExpressions |
428
- DirectedRelationExpressions
429
- ;
430
-
431
- InOutRelationExpressions infers RelationExpression:
432
- IncomingRelationExpression ({infer InOutRelationExpression.inout=current} '->')?
433
- ;
434
-
435
- IncomingRelationExpression:
436
- '->' to=ElementExpression;
437
-
438
- DirectedRelationExpressions infers RelationExpression:
439
- OutgoingRelationExpression ({infer DirectedRelationExpression.source=current} target=ElementExpression)?
440
- ;
441
-
442
- OutgoingRelationExpression:
443
- from=ElementExpression
444
- (isBidirectional?='<->' | '->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
445
- ;
446
-
447
- // Comma-separated list of ElementExpressions
448
- ElementExpressionsIterator:
449
- value=ElementExpression ({infer ElementExpressionsIterator.prev=current} ',' (value=ElementExpression)?)*
450
- ;
451
-
452
- DynamicViewIncludePredicate:
453
- 'include' predicates=DynamicViewPredicateIterator
454
- ;
455
-
456
- DynamicViewGlobalPredicateRef:
457
- 'global' 'predicate' predicate=[GlobalDynamicPredicateGroup];
458
-
459
- DynamicViewPredicateIterator:
460
- value=ElementPredicate ({infer DynamicViewPredicateIterator.prev=current} ',' (value=ElementPredicate)?)*
461
- ;
462
-
463
- ViewRuleStyle:
464
- 'style' target=ElementExpressionsIterator '{'
465
- props+=(
466
- StyleProperty |
467
- NotationProperty
468
- )*
469
- '}';
470
-
471
- ViewRuleGlobalStyle:
472
- 'global' 'style' style=[GlobalStyleId];
473
-
474
- ViewRuleStyleOrGlobalRef:
475
- ViewRuleStyle | ViewRuleGlobalStyle;
476
-
477
- ViewRuleAutoLayout:
478
- 'autoLayout' direction=ViewLayoutDirection (
479
- rankSep=Number (
480
- nodeSep=Number)?
481
- )?;
482
-
483
- NotationProperty:
484
- key='notation' ':'? value=String ';'?
485
- ;
486
- NotesProperty:
487
- key='notes' ':'? value=String ';'?
488
- ;
489
-
490
- CustomElementProperties: '{'
491
- props+=(
492
- NavigateToProperty |
493
- ElementStringProperty |
494
- NotationProperty |
495
- StyleProperty
496
- )*
497
- '}'
498
- ;
499
-
500
- CustomRelationProperties: '{'
501
- props+=(
502
- RelationNavigateToProperty |
503
- RelationStringProperty |
504
- NotationProperty |
505
- NotesProperty |
506
- RelationshipStyleProperty
507
- )*
508
- '}'
509
- ;
510
-
511
- NavigateToProperty:
512
- key='navigateTo' value=ViewRef;
513
-
514
- RelationNavigateToProperty:
515
- key='navigateTo' value=DynamicViewRef;
516
-
517
- // Deployment -------------------------------------
518
-
519
- ModelDeployments:
520
- name='deployment' '{'
521
- elements+=(
522
- DeploymentNode |
523
- DeploymentRelation
524
- )*
525
- '}';
526
-
527
- type DeploymentElement = DeploymentNode | DeployedInstance;
528
-
529
- DeploymentNode:
530
- (
531
- kind=[DeploymentNodeKind:Id] name=Id |
532
- name=Id Eq kind=[DeploymentNodeKind:Id]
533
- )
534
- title=String?
535
- body=DeploymentNodeBody?
536
- ;
537
-
538
- DeploymentNodeBody: '{'
539
- tags=Tags?
540
- props+=ElementProperty*
541
- elements+=(
542
- DeployedInstance |
543
- DeploymentRelation |
544
- DeploymentNode
545
- )*
546
- '}';
547
-
548
- DeployedInstance:
549
- (name=Id Eq)?
550
- 'instanceOf'
551
- element=ElementRef
552
- title=String?
553
- body=DeployedInstanceBody?
554
- ';'?
555
- ;
556
-
557
- DeployedInstanceBody: '{'
558
- tags=Tags?
559
- props+=ElementProperty*
560
- '}';
561
-
562
- type Referenceable = DeploymentNode | DeployedInstance | Element;
563
- // Reference to Elements in logical or deployment model
564
- // Scope computation is based on the parent element:
565
- // - If parent is DeploymentNode, then it can reference nested DeploymentNodes and DeployedInstances
566
- // - If parent is DeployedInstance, then it can reference nested Element
567
- // - If parent is Element, then it can reference nested Element
568
- // Mix of DeploymentRef and ElementRef
569
- FqnRef:
570
- value=[Referenceable:Id] ({infer FqnRef.parent=current} StickyDot value=[Referenceable:Id])*;
571
-
572
- DeploymentRelation:
573
- source=FqnRef
574
- ('->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
575
- target=FqnRef
576
- (
577
- title=String
578
- technology=String?
579
- )?
580
- tags=Tags?
581
- body=DeploymentRelationBody?
582
- ;
583
-
584
- DeploymentRelationBody: '{'
585
- tags=Tags?
586
- props+=RelationProperty*
587
- '}'
588
- ;
589
-
590
- DeploymentView:
591
- 'deployment' 'view' name=Id body=DeploymentViewBody?
592
- ;
593
-
594
- DeploymentViewBody: '{'
595
- tags=Tags?
596
- props+=ViewProperty*
597
- rules+=DeploymentViewRule*
598
- '}';
599
-
600
- DeploymentViewRule:
601
- DeploymentViewRulePredicate |
602
- DeploymentViewRuleStyle |
603
- ViewRuleAutoLayout
604
- ;
605
-
606
- DeploymentViewRuleStyle:
607
- 'style' targets=FqnExpressions '{'
608
- props+=(
609
- StyleProperty |
610
- NotationProperty
611
- )*
612
- '}';
613
-
614
-
615
- DeploymentViewRulePredicate:
616
- (isInclude?='include' | 'exclude')
617
- expr=DeploymentViewRulePredicateExpression
618
- ;
619
-
620
- DeploymentViewRulePredicateExpression:
621
- value=ExpressionV2 ({infer DeploymentViewRulePredicateExpression.prev=current} ',' (value=ExpressionV2)?)*
622
- ;
623
-
624
- ExpressionV2:
625
- RelationPredicateOrWhereV2 |
626
- FqnExpr
627
- ;
628
-
629
- RelationPredicateOrWhereV2:
630
- RelationExpr ({infer RelationPredicateWhereV2.subject=current} 'where' where=WhereRelationExpression?)?
631
- ;
632
-
633
- FqnExpr:
634
- {infer WildcardExpression} isWildcard?='*' |
635
- FqnRefExpr
636
- ;
637
-
638
- FqnRefExpr:
639
- ref=FqnRef selector=(DotUnderscore | DotWildcard)?
640
- ;
641
-
642
- RelationExpr:
643
- InOutRelationExpr |
644
- DirectedRelationExpr
645
- ;
646
-
647
- InOutRelationExpr infers RelationExpr:
648
- IncomingRelationExpr ({infer InOutRelationExpr.inout=current} '->')?
649
- ;
650
-
651
- IncomingRelationExpr:
652
- '->' to=FqnExpr;
653
-
654
- DirectedRelationExpr infers RelationExpr:
655
- OutgoingRelationExpr ({infer DirectedRelationExpr.source=current} target=FqnExpr)?
656
- ;
657
-
658
- OutgoingRelationExpr:
659
- from=FqnExpr
660
- (isBidirectional?='<->' | '->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
661
- ;
662
-
663
- FqnExpressions:
664
- value=FqnExpr ({infer FqnExpressions.prev=current} ',' (value=FqnExpr)?)*
665
- ;
666
- // Global -------------------------------------
667
-
668
- Globals:
669
- name='global' '{'
670
- (
671
- predicates+=(GlobalPredicateGroup | GlobalDynamicPredicateGroup)*
672
- styles+=(GlobalStyle | GlobalStyleGroup)*
673
- )*
674
- '}';
675
-
676
- GlobalPredicateGroup:
677
- 'predicateGroup' name=IdTerminal '{'
678
- predicates+=ViewRulePredicate*
679
- '}';
680
-
681
- GlobalDynamicPredicateGroup:
682
- 'dynamicPredicateGroup' name=IdTerminal '{'
683
- predicates+=DynamicViewIncludePredicate*
684
- '}';
685
-
686
- GlobalStyleId:
687
- name=IdTerminal;
688
-
689
- GlobalStyle:
690
- 'style' id=GlobalStyleId target=ElementExpressionsIterator '{'
691
- props+=(
692
- StyleProperty |
693
- NotationProperty
694
- )*
695
- '}';
696
-
697
- GlobalStyleGroup:
698
- 'styleGroup' id=GlobalStyleId '{'
699
- styles+=ViewRuleStyle*
700
- '}';
701
-
702
- type FqnReferenceable = Referenceable | Element | ExtendElement;
703
-
704
- // Common properties -------------------------------------
705
-
706
- LinkProperty:
707
- key='link' ':'? value=Uri title=String? ';'?;
708
- ColorProperty:
709
- key='color' ':'? (themeColor=ThemeColor | customColor=[CustomColor:CustomColorId]) ';'?;
710
-
711
- OpacityProperty:
712
- key='opacity' ':'? value=Percent ';'?;
713
-
714
- // Element properties -------------------------------------
715
- IconProperty:
716
- key='icon' ':'? (libicon=[LibIcon:IconId] | value=('none'|Uri)) ';'?;
717
-
718
- ShapeProperty:
719
- key='shape' ':'? value=ElementShape ';'?;
720
-
721
-
722
- BorderStyleValue returns string:
723
- LineOptions | 'none';
724
-
725
- BorderProperty:
726
- key='border' ':'? value=BorderStyleValue ';'?;
727
-
728
- StyleProperty:
729
- ColorProperty |
730
- ShapeProperty |
731
- BorderProperty |
732
- OpacityProperty |
733
- IconProperty;
734
-
735
- ElementStyleProperty:
736
- key='style' '{'
737
- props+=StyleProperty*
738
- '}';
739
-
740
-
741
- // -------------------------
742
- // Relationship Style Properties
743
- LineProperty:
744
- key='line' ':'? value=LineOptions ';'?;
745
- ArrowProperty:
746
- key=('head' | 'tail') ':'? value=ArrowType ';'?;
747
-
748
- RelationshipStyleProperty:
749
- ColorProperty | LineProperty | ArrowProperty;
750
-
751
- LineOptions returns string:
752
- 'solid' |
753
- 'dashed' |
754
- 'dotted'
755
- ;
756
-
757
- ArrowType returns string:
758
- 'none' |
759
- 'normal' |
760
- 'onormal' |
761
- 'dot' |
762
- 'odot' |
763
- 'diamond' |
764
- 'odiamond' |
765
- 'crow' |
766
- 'open' |
767
- 'vee'
768
- ;
769
-
770
- ThemeColor returns string:
771
- 'primary' | 'secondary' | 'muted' | 'slate' | 'blue' | 'indigo' | 'sky' | 'red' | 'gray' | 'green' | 'amber';
772
- ElementShape returns string:
773
- 'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
774
- Participant returns string:
775
- 'source' | 'target';
776
-
777
- CustomColorValue returns string:
778
- Hash (Id | Hex | Number);
779
-
780
- IconId returns string:
781
- LIB_ICON;
782
-
783
- Uri returns string:
784
- URI_WITH_SCHEMA | URI_RELATIVE;
785
-
786
- TagId returns string:
787
- Hash Id;
788
-
789
- DotId returns string:
790
- Dot Id;
791
-
792
- CustomColorId returns string:
793
- IdTerminal | ElementShape | ArrowType | LineOptions | 'element' | 'model';
794
-
795
- Id returns string:
796
- IdTerminal | ElementShape | ThemeColor | ArrowType | LineOptions | Participant | 'element' | 'model' | 'group' | 'node' | 'deployment' | 'instance';
797
-
798
- fragment EqOperator:
799
- (
800
- operator=(Eq | NotEqual) |
801
- operator="is" not?='not'?
802
- )
803
- ;
804
-
805
- fragment IsEqual:
806
- isEqual?=Eq | NotEqual;
807
-
808
- // -----------------------------------
809
- // Symbols
810
- // terminal fragment HASH: '#';
811
- // terminal fragment UNDERSCORE: '_';
812
- // terminal fragment DASH: '-';
813
- // terminal fragment LETTER: /[^\W\d_]/;
814
- // terminal fragment DIGIT: /[0-9]/;
815
- // terminal fragment NEWLINE: /[\r?\n]/;
816
- // terminal fragment SPACE: /[^\S\r\n]/;
817
-
818
- // -------------------------
819
- // Comments
820
- hidden terminal BLOCK_COMMENT: /\/\*[\s\S]*?\*\//;
821
- hidden terminal LINE_COMMENT: /\/\/[^\n\r]*/;
822
- hidden terminal WS: /[\t ]+/;
823
- hidden terminal NL: /[\r\n]+/;
824
-
825
- // -----------------------------------
826
- // Terminals
827
- //terminal LineStartWithDash: /(?<=([\r?\n][^\S\r\n]*))-/;
828
-
829
- // LibIcons
830
- terminal LIB_ICON: /(aws|azure|gcp|tech):[-\w]*/;
831
-
832
- terminal URI_WITH_SCHEMA: /\w+:\/\/\S+/;
833
- terminal URI_RELATIVE: /\.{0,2}\/[^\/]\S+/;
834
-
835
- terminal DotUnderscore: /\b\._(?![_a-zA-Z])/;
836
- terminal DotWildcard: /\b\.\*{1,2}/;
837
- terminal Hash: '#';
838
-
839
- // No space allowed before dot
840
- terminal StickyDot: /\b\./;
841
- terminal Dot: '.';
842
- terminal NotEqual: /\!\={1,2}/;
843
- terminal Eq: /\={1,2}/;
844
- terminal Percent: /\b\d+%/;
845
-
846
- terminal String: /"[^"]*"|'[^']*'/;
847
-
848
- // terminal TagId: HASH LETTER (LETTER | DIGIT | UNDERSCORE | DASH)*;
849
- // terminal IdTerminal: (LETTER | UNDERSCORE+ (LETTER | DIGIT)) (LETTER | DIGIT | UNDERSCORE | DASH)*;
850
- terminal IdTerminal: /[_]*[a-zA-Z][-\w]*/;
851
- terminal Number returns number: /\b\d+\b/;
852
- terminal Hex: /\b[a-zA-Z0-9]+\b/;