@likec4/language-server 1.18.0 → 1.19.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.
Files changed (250) hide show
  1. package/dist/LikeC4FileSystem.d.ts +13 -0
  2. package/dist/LikeC4FileSystem.js +27 -0
  3. package/dist/Rpc.d.ts +9 -0
  4. package/dist/Rpc.js +132 -0
  5. package/dist/ast.d.ts +200 -0
  6. package/dist/ast.js +276 -0
  7. package/dist/browser.d.ts +7 -20
  8. package/dist/browser.js +13 -0
  9. package/dist/documentation/documentation-provider.d.ts +8 -0
  10. package/dist/documentation/documentation-provider.js +46 -0
  11. package/dist/documentation/index.d.ts +1 -0
  12. package/dist/documentation/index.js +1 -0
  13. package/dist/formatting/LikeC4Formatter.d.ts +27 -0
  14. package/dist/formatting/LikeC4Formatter.js +261 -0
  15. package/dist/formatting/utils.d.ts +6 -0
  16. package/dist/formatting/utils.js +15 -0
  17. package/dist/generated/ast.d.ts +1242 -0
  18. package/dist/generated/ast.js +1945 -0
  19. package/dist/generated/grammar.d.ts +6 -0
  20. package/dist/generated/grammar.js +3 -0
  21. package/dist/generated/module.d.ts +9 -0
  22. package/dist/generated/module.js +23 -0
  23. package/dist/generated-lib/icons.d.ts +1 -0
  24. package/dist/{likec4lib.mjs → generated-lib/icons.js} +1 -6
  25. package/dist/index.d.ts +9 -31
  26. package/dist/index.js +14 -0
  27. package/dist/like-c4.langium +845 -0
  28. package/dist/likec4lib.d.ts +4 -6
  29. package/dist/likec4lib.js +4 -0
  30. package/dist/logger.d.ts +7 -0
  31. package/dist/logger.js +73 -0
  32. package/dist/lsp/CodeLensProvider.d.ts +9 -0
  33. package/dist/lsp/CodeLensProvider.js +40 -0
  34. package/dist/lsp/CompletionProvider.d.ts +6 -0
  35. package/dist/lsp/CompletionProvider.js +135 -0
  36. package/dist/lsp/DocumentHighlightProvider.d.ts +9 -0
  37. package/dist/lsp/DocumentHighlightProvider.js +10 -0
  38. package/dist/lsp/DocumentLinkProvider.d.ts +11 -0
  39. package/dist/lsp/DocumentLinkProvider.js +49 -0
  40. package/dist/lsp/DocumentSymbolProvider.d.ts +32 -0
  41. package/dist/lsp/DocumentSymbolProvider.js +274 -0
  42. package/dist/lsp/HoverProvider.d.ts +10 -0
  43. package/dist/lsp/HoverProvider.js +69 -0
  44. package/dist/lsp/RenameProvider.d.ts +5 -0
  45. package/dist/lsp/RenameProvider.js +6 -0
  46. package/dist/lsp/SemanticTokenProvider.d.ts +7 -0
  47. package/dist/lsp/SemanticTokenProvider.js +297 -0
  48. package/dist/lsp/index.d.ts +7 -0
  49. package/dist/lsp/index.js +7 -0
  50. package/dist/model/deployments-index.d.ts +60 -0
  51. package/dist/model/deployments-index.js +181 -0
  52. package/dist/model/fqn-computation.d.ts +3 -0
  53. package/dist/model/fqn-computation.js +72 -0
  54. package/dist/model/fqn-index.d.ts +25 -0
  55. package/dist/model/fqn-index.js +96 -0
  56. package/dist/model/index.d.ts +6 -0
  57. package/dist/model/index.js +6 -0
  58. package/dist/model/model-builder.d.ts +32 -0
  59. package/dist/model/model-builder.js +598 -0
  60. package/dist/model/model-locator.d.ts +23 -0
  61. package/dist/model/model-locator.js +126 -0
  62. package/dist/model/model-parser-where.d.ts +3 -0
  63. package/dist/model/model-parser-where.js +70 -0
  64. package/dist/model/model-parser.d.ts +292 -0
  65. package/dist/model/model-parser.js +72 -0
  66. package/dist/model/parser/Base.d.ts +28 -0
  67. package/dist/model/parser/Base.js +87 -0
  68. package/dist/model/parser/DeploymentModelParser.d.ts +33 -0
  69. package/dist/model/parser/DeploymentModelParser.js +162 -0
  70. package/dist/model/parser/DeploymentViewParser.d.ts +38 -0
  71. package/dist/model/parser/DeploymentViewParser.js +98 -0
  72. package/dist/model/parser/FqnRefParser.d.ts +29 -0
  73. package/dist/model/parser/FqnRefParser.js +108 -0
  74. package/dist/model/parser/GlobalsParser.d.ts +66 -0
  75. package/dist/model/parser/GlobalsParser.js +80 -0
  76. package/dist/model/parser/ModelParser.d.ts +27 -0
  77. package/dist/model/parser/ModelParser.js +122 -0
  78. package/dist/model/parser/PredicatesParser.d.ts +34 -0
  79. package/dist/model/parser/PredicatesParser.js +272 -0
  80. package/dist/model/parser/SpecificationParser.d.ts +27 -0
  81. package/dist/model/parser/SpecificationParser.js +120 -0
  82. package/dist/model/parser/ViewsParser.d.ts +64 -0
  83. package/dist/model/parser/ViewsParser.js +377 -0
  84. package/dist/model-change/ModelChanges.d.ts +15 -0
  85. package/dist/model-change/ModelChanges.js +89 -0
  86. package/dist/model-change/changeElementStyle.d.ts +16 -0
  87. package/dist/model-change/changeElementStyle.js +136 -0
  88. package/dist/model-change/changeViewLayout.d.ts +12 -0
  89. package/dist/model-change/changeViewLayout.js +32 -0
  90. package/dist/model-change/saveManualLayout.d.ts +11 -0
  91. package/dist/model-change/saveManualLayout.js +27 -0
  92. package/dist/module.d.ts +70 -0
  93. package/dist/module.js +162 -0
  94. package/dist/protocol.d.ts +38 -23
  95. package/dist/protocol.js +15 -0
  96. package/dist/references/index.d.ts +3 -0
  97. package/dist/references/index.js +3 -0
  98. package/dist/references/name-provider.d.ts +9 -0
  99. package/dist/references/name-provider.js +33 -0
  100. package/dist/references/scope-computation.d.ts +20 -0
  101. package/dist/references/scope-computation.js +281 -0
  102. package/dist/references/scope-provider.d.ts +16 -0
  103. package/dist/references/scope-provider.js +165 -0
  104. package/dist/shared/NodeKindProvider.d.ts +15 -0
  105. package/dist/shared/NodeKindProvider.js +108 -0
  106. package/dist/shared/WorkspaceManager.d.ts +18 -0
  107. package/dist/shared/WorkspaceManager.js +36 -0
  108. package/dist/shared/WorkspaceSymbolProvider.d.ts +3 -0
  109. package/dist/shared/WorkspaceSymbolProvider.js +3 -0
  110. package/dist/shared/index.d.ts +3 -0
  111. package/dist/shared/index.js +3 -0
  112. package/dist/test/index.d.ts +1 -0
  113. package/dist/test/index.js +1 -0
  114. package/dist/test/setup.d.ts +1 -0
  115. package/dist/test/setup.js +7 -0
  116. package/dist/test/testServices.d.ts +22 -0
  117. package/dist/test/testServices.js +119 -0
  118. package/dist/utils/elementRef.d.ts +11 -0
  119. package/dist/utils/elementRef.js +15 -0
  120. package/dist/utils/fqnRef.d.ts +8 -0
  121. package/dist/utils/fqnRef.js +46 -0
  122. package/dist/utils/index.d.ts +1 -0
  123. package/dist/utils/index.js +1 -0
  124. package/dist/utils/printDocs.d.ts +2 -0
  125. package/dist/utils/printDocs.js +1 -0
  126. package/dist/utils/stringHash.d.ts +1 -0
  127. package/dist/utils/stringHash.js +5 -0
  128. package/dist/validation/_shared.d.ts +3 -0
  129. package/dist/validation/_shared.js +22 -0
  130. package/dist/validation/deployment-checks.d.ts +6 -0
  131. package/dist/validation/deployment-checks.js +114 -0
  132. package/dist/validation/dynamic-view-rule.d.ts +4 -0
  133. package/dist/validation/dynamic-view-rule.js +17 -0
  134. package/dist/validation/dynamic-view-step.d.ts +4 -0
  135. package/dist/validation/dynamic-view-step.js +29 -0
  136. package/dist/validation/element.d.ts +4 -0
  137. package/dist/validation/element.js +49 -0
  138. package/dist/validation/index.d.ts +15 -0
  139. package/dist/validation/index.js +152 -0
  140. package/dist/validation/property-checks.d.ts +6 -0
  141. package/dist/validation/property-checks.js +39 -0
  142. package/dist/validation/relation.d.ts +5 -0
  143. package/dist/validation/relation.js +56 -0
  144. package/dist/validation/specification.d.ts +11 -0
  145. package/dist/validation/specification.js +136 -0
  146. package/dist/validation/view-predicates/element-with.d.ts +4 -0
  147. package/dist/validation/view-predicates/element-with.js +31 -0
  148. package/dist/validation/view-predicates/expanded-element.d.ts +4 -0
  149. package/dist/validation/view-predicates/expanded-element.js +12 -0
  150. package/dist/validation/view-predicates/expression-v2.d.ts +5 -0
  151. package/dist/validation/view-predicates/expression-v2.js +83 -0
  152. package/dist/validation/view-predicates/incoming.d.ts +4 -0
  153. package/dist/validation/view-predicates/incoming.js +16 -0
  154. package/dist/validation/view-predicates/index.d.ts +6 -0
  155. package/dist/validation/view-predicates/index.js +6 -0
  156. package/dist/validation/view-predicates/outgoing.d.ts +4 -0
  157. package/dist/validation/view-predicates/outgoing.js +16 -0
  158. package/dist/validation/view-predicates/relation-with.d.ts +4 -0
  159. package/dist/validation/view-predicates/relation-with.js +13 -0
  160. package/dist/validation/view.d.ts +4 -0
  161. package/dist/validation/view.js +23 -0
  162. package/dist/view-utils/assignNavigateTo.d.ts +2 -0
  163. package/dist/view-utils/assignNavigateTo.js +25 -0
  164. package/dist/view-utils/index.d.ts +2 -0
  165. package/dist/view-utils/index.js +2 -0
  166. package/dist/view-utils/manual-layout.d.ts +7 -0
  167. package/dist/view-utils/manual-layout.js +99 -0
  168. package/dist/view-utils/resolve-relative-paths.d.ts +2 -0
  169. package/dist/view-utils/resolve-relative-paths.js +78 -0
  170. package/dist/views/configurable-layouter.d.ts +7 -0
  171. package/dist/views/configurable-layouter.js +55 -0
  172. package/dist/views/index.d.ts +1 -0
  173. package/dist/views/index.js +1 -0
  174. package/dist/views/likec4-views.d.ts +26 -0
  175. package/dist/views/likec4-views.js +113 -0
  176. package/package.json +40 -54
  177. package/src/LikeC4FileSystem.ts +22 -21
  178. package/src/Rpc.ts +13 -7
  179. package/src/ast.ts +44 -133
  180. package/src/browser.ts +11 -11
  181. package/src/documentation/documentation-provider.ts +52 -0
  182. package/src/documentation/index.ts +1 -0
  183. package/src/generated/ast.ts +177 -177
  184. package/src/generated/grammar.ts +1 -1
  185. package/src/index.ts +13 -9
  186. package/src/like-c4.langium +37 -34
  187. package/src/logger.ts +34 -55
  188. package/src/lsp/CompletionProvider.ts +4 -4
  189. package/src/lsp/DocumentSymbolProvider.ts +110 -28
  190. package/src/lsp/HoverProvider.ts +5 -3
  191. package/src/lsp/SemanticTokenProvider.ts +2 -2
  192. package/src/model/deployments-index.ts +18 -14
  193. package/src/model/fqn-computation.ts +8 -8
  194. package/src/model/model-builder.ts +62 -60
  195. package/src/model/model-parser.ts +62 -1574
  196. package/src/model/parser/Base.ts +107 -0
  197. package/src/model/parser/DeploymentModelParser.ts +192 -0
  198. package/src/model/parser/DeploymentViewParser.ts +116 -0
  199. package/src/model/parser/FqnRefParser.ts +118 -0
  200. package/src/model/parser/GlobalsParser.ts +96 -0
  201. package/src/model/parser/ModelParser.ts +141 -0
  202. package/src/model/parser/PredicatesParser.ts +291 -0
  203. package/src/model/parser/SpecificationParser.ts +133 -0
  204. package/src/model/parser/ViewsParser.ts +428 -0
  205. package/src/module.ts +71 -25
  206. package/src/protocol.ts +29 -4
  207. package/src/references/scope-computation.ts +35 -35
  208. package/src/references/scope-provider.ts +13 -7
  209. package/src/utils/{deploymentRef.ts → fqnRef.ts} +27 -2
  210. package/src/validation/_shared.ts +0 -1
  211. package/src/validation/deployment-checks.ts +49 -62
  212. package/src/validation/dynamic-view-rule.ts +5 -4
  213. package/src/validation/dynamic-view-step.ts +23 -26
  214. package/src/validation/index.ts +100 -9
  215. package/src/validation/property-checks.ts +11 -10
  216. package/src/validation/specification.ts +38 -38
  217. package/src/validation/view-predicates/element-with.ts +6 -5
  218. package/src/validation/view-predicates/expanded-element.ts +6 -5
  219. package/src/validation/view-predicates/expression-v2.ts +101 -0
  220. package/src/validation/view-predicates/incoming.ts +6 -5
  221. package/src/validation/view-predicates/index.ts +1 -1
  222. package/src/validation/view-predicates/outgoing.ts +6 -5
  223. package/src/validation/view-predicates/relation-with.ts +6 -5
  224. package/src/validation/view.ts +5 -5
  225. package/src/view-utils/assignNavigateTo.ts +1 -1
  226. package/src/view-utils/manual-layout.ts +25 -0
  227. package/src/views/configurable-layouter.ts +65 -0
  228. package/src/views/index.ts +1 -0
  229. package/src/views/likec4-views.ts +139 -0
  230. package/dist/browser.cjs +0 -25
  231. package/dist/browser.d.cts +0 -23
  232. package/dist/browser.d.mts +0 -23
  233. package/dist/browser.mjs +0 -20
  234. package/dist/index.cjs +0 -53
  235. package/dist/index.d.cts +0 -34
  236. package/dist/index.d.mts +0 -34
  237. package/dist/index.mjs +0 -46
  238. package/dist/likec4lib.cjs +0 -1546
  239. package/dist/likec4lib.d.cts +0 -6
  240. package/dist/likec4lib.d.mts +0 -6
  241. package/dist/protocol.cjs +0 -25
  242. package/dist/protocol.d.cts +0 -48
  243. package/dist/protocol.d.mts +0 -48
  244. package/dist/protocol.mjs +0 -17
  245. package/dist/shared/language-server.CO_nmHiL.cjs +0 -7689
  246. package/dist/shared/language-server.Da6ey08o.d.cts +0 -1619
  247. package/dist/shared/language-server.De7S3e5Z.d.ts +0 -1619
  248. package/dist/shared/language-server.Dj4iDjtB.d.mts +0 -1619
  249. package/dist/shared/language-server.oO_9JoAG.mjs +0 -7666
  250. package/src/validation/view-predicates/deployments.ts +0 -56
@@ -0,0 +1,845 @@
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
+ ;
418
+
419
+ type WhereTagEqual = WhereElementTag | WhereRelationTag;
420
+ type WhereKindEqual = WhereElementKind | WhereRelationKind;
421
+
422
+ type WhereExpression = WhereElementExpression | WhereRelationExpression;
423
+
424
+ RelationExpression:
425
+ InOutRelationExpressions |
426
+ DirectedRelationExpressions
427
+ ;
428
+
429
+ InOutRelationExpressions infers RelationExpression:
430
+ IncomingRelationExpression ({infer InOutRelationExpression.inout=current} '->')?
431
+ ;
432
+
433
+ IncomingRelationExpression:
434
+ '->' to=ElementExpression;
435
+
436
+ DirectedRelationExpressions infers RelationExpression:
437
+ OutgoingRelationExpression ({infer DirectedRelationExpression.source=current} target=ElementExpression)?
438
+ ;
439
+
440
+ OutgoingRelationExpression:
441
+ from=ElementExpression
442
+ (isBidirectional?='<->' | '->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
443
+ ;
444
+
445
+ // Comma-separated list of ElementExpressions
446
+ ElementExpressionsIterator:
447
+ value=ElementExpression ({infer ElementExpressionsIterator.prev=current} ',' (value=ElementExpression)?)*
448
+ ;
449
+
450
+ DynamicViewIncludePredicate:
451
+ 'include' predicates=DynamicViewPredicateIterator
452
+ ;
453
+
454
+ DynamicViewGlobalPredicateRef:
455
+ 'global' 'predicate' predicate=[GlobalDynamicPredicateGroup];
456
+
457
+ DynamicViewPredicateIterator:
458
+ value=ElementPredicate ({infer DynamicViewPredicateIterator.prev=current} ',' (value=ElementPredicate)?)*
459
+ ;
460
+
461
+ ViewRuleStyle:
462
+ 'style' target=ElementExpressionsIterator '{'
463
+ props+=(
464
+ StyleProperty |
465
+ NotationProperty
466
+ )*
467
+ '}';
468
+
469
+ ViewRuleGlobalStyle:
470
+ 'global' 'style' style=[GlobalStyleId];
471
+
472
+ ViewRuleStyleOrGlobalRef:
473
+ ViewRuleStyle | ViewRuleGlobalStyle;
474
+
475
+ ViewRuleAutoLayout:
476
+ 'autoLayout' direction=ViewLayoutDirection (
477
+ rankSep=Number (
478
+ nodeSep=Number)?
479
+ )?;
480
+
481
+ NotationProperty:
482
+ key='notation' ':'? value=String ';'?
483
+ ;
484
+ NotesProperty:
485
+ key='notes' ':'? value=String ';'?
486
+ ;
487
+
488
+ CustomElementProperties: '{'
489
+ props+=(
490
+ NavigateToProperty |
491
+ ElementStringProperty |
492
+ NotationProperty |
493
+ StyleProperty
494
+ )*
495
+ '}'
496
+ ;
497
+
498
+ CustomRelationProperties: '{'
499
+ props+=(
500
+ RelationNavigateToProperty |
501
+ RelationStringProperty |
502
+ NotationProperty |
503
+ NotesProperty |
504
+ RelationshipStyleProperty
505
+ )*
506
+ '}'
507
+ ;
508
+
509
+ NavigateToProperty:
510
+ key='navigateTo' value=ViewRef;
511
+
512
+ RelationNavigateToProperty:
513
+ key='navigateTo' value=DynamicViewRef;
514
+
515
+ // Deployment -------------------------------------
516
+
517
+ ModelDeployments:
518
+ name='deployment' '{'
519
+ elements+=(
520
+ DeploymentNode |
521
+ DeploymentRelation
522
+ )*
523
+ '}';
524
+
525
+ type DeploymentElement = DeploymentNode | DeployedInstance;
526
+
527
+ DeploymentNode:
528
+ (
529
+ kind=[DeploymentNodeKind:Id] name=Id |
530
+ name=Id Eq kind=[DeploymentNodeKind:Id]
531
+ )
532
+ title=String?
533
+ body=DeploymentNodeBody?
534
+ ;
535
+
536
+ DeploymentNodeBody: '{'
537
+ tags=Tags?
538
+ props+=ElementProperty*
539
+ elements+=(
540
+ DeployedInstance |
541
+ DeploymentRelation |
542
+ DeploymentNode
543
+ )*
544
+ '}';
545
+
546
+ DeployedInstance:
547
+ (name=Id Eq)?
548
+ 'instanceOf'
549
+ element=ElementRef
550
+ title=String?
551
+ body=DeployedInstanceBody?
552
+ ';'?
553
+ ;
554
+
555
+ DeployedInstanceBody: '{'
556
+ tags=Tags?
557
+ props+=ElementProperty*
558
+ '}';
559
+
560
+ type Referenceable = DeploymentNode | DeployedInstance | Element;
561
+ // Reference to Elements in logical or deployment model
562
+ // Scope computation is based on the parent element:
563
+ // - If parent is DeploymentNode, then it can reference nested DeploymentNodes and DeployedInstances
564
+ // - If parent is DeployedInstance, then it can reference nested Element
565
+ // - If parent is Element, then it can reference nested Element
566
+ // Mix of DeploymentRef and ElementRef
567
+ FqnRef:
568
+ value=[Referenceable:Id] ({infer FqnRef.parent=current} StickyDot value=[Referenceable:Id])*;
569
+
570
+ DeploymentRelation:
571
+ source=FqnRef
572
+ ('->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
573
+ target=FqnRef
574
+ (
575
+ title=String
576
+ technology=String?
577
+ )?
578
+ tags=Tags?
579
+ body=DeploymentRelationBody?
580
+ ;
581
+
582
+ DeploymentRelationBody: '{'
583
+ tags=Tags?
584
+ props+=RelationProperty*
585
+ '}'
586
+ ;
587
+
588
+ DeploymentView:
589
+ 'deployment' 'view' name=Id body=DeploymentViewBody?
590
+ ;
591
+
592
+ DeploymentViewBody: '{'
593
+ tags=Tags?
594
+ props+=ViewProperty*
595
+ rules+=DeploymentViewRule*
596
+ '}';
597
+
598
+ DeploymentViewRule:
599
+ DeploymentViewRulePredicate |
600
+ DeploymentViewRuleStyle |
601
+ ViewRuleAutoLayout
602
+ ;
603
+
604
+ DeploymentViewRuleStyle:
605
+ 'style' targets=FqnExpressions '{'
606
+ props+=(
607
+ StyleProperty |
608
+ NotationProperty
609
+ )*
610
+ '}';
611
+
612
+
613
+ DeploymentViewRulePredicate:
614
+ (isInclude?='include' | 'exclude')
615
+ expr=DeploymentViewRulePredicateExpression
616
+ ;
617
+
618
+ DeploymentViewRulePredicateExpression:
619
+ value=ExpressionV2 ({infer DeploymentViewRulePredicateExpression.prev=current} ',' (value=ExpressionV2)?)*
620
+ ;
621
+
622
+ ExpressionV2:
623
+ RelationExpr |
624
+ FqnExpr
625
+ ;
626
+
627
+
628
+ FqnExpr:
629
+ {infer WildcardExpression} isWildcard?='*' |
630
+ FqnRefExpr
631
+ ;
632
+
633
+ FqnRefExpr:
634
+ ref=FqnRef selector=(DotUnderscore | DotWildcard)?
635
+ ;
636
+
637
+ RelationExpr:
638
+ InOutRelationExpr |
639
+ DirectedRelationExpr
640
+ ;
641
+
642
+ InOutRelationExpr infers RelationExpr:
643
+ IncomingRelationExpr ({infer InOutRelationExpr.inout=current} '->')?
644
+ ;
645
+
646
+ IncomingRelationExpr:
647
+ '->' to=FqnExpr;
648
+
649
+ DirectedRelationExpr infers RelationExpr:
650
+ OutgoingRelationExpr ({infer DirectedRelationExpr.source=current} target=FqnExpr)?
651
+ ;
652
+
653
+ OutgoingRelationExpr:
654
+ from=FqnExpr
655
+ (isBidirectional?='<->' | '->' | '-[' kind=[RelationshipKind:Id] ']->' | kind=[RelationshipKind:DotId])
656
+ ;
657
+
658
+ FqnExpressions:
659
+ value=FqnExpr ({infer FqnExpressions.prev=current} ',' (value=FqnExpr)?)*
660
+ ;
661
+ // Global -------------------------------------
662
+
663
+ Globals:
664
+ name='global' '{'
665
+ (
666
+ predicates+=(GlobalPredicateGroup | GlobalDynamicPredicateGroup)*
667
+ styles+=(GlobalStyle | GlobalStyleGroup)*
668
+ )*
669
+ '}';
670
+
671
+ GlobalPredicateGroup:
672
+ 'predicateGroup' name=IdTerminal '{'
673
+ predicates+=ViewRulePredicate*
674
+ '}';
675
+
676
+ GlobalDynamicPredicateGroup:
677
+ 'dynamicPredicateGroup' name=IdTerminal '{'
678
+ predicates+=DynamicViewIncludePredicate*
679
+ '}';
680
+
681
+ GlobalStyleId:
682
+ name=IdTerminal;
683
+
684
+ GlobalStyle:
685
+ 'style' id=GlobalStyleId target=ElementExpressionsIterator '{'
686
+ props+=(
687
+ StyleProperty |
688
+ NotationProperty
689
+ )*
690
+ '}';
691
+
692
+ GlobalStyleGroup:
693
+ 'styleGroup' id=GlobalStyleId '{'
694
+ styles+=ViewRuleStyle*
695
+ '}';
696
+
697
+ type FqnReferenceable = Referenceable | Element | ExtendElement;
698
+
699
+ // Common properties -------------------------------------
700
+
701
+ LinkProperty:
702
+ key='link' ':'? value=Uri title=String? ';'?;
703
+ ColorProperty:
704
+ key='color' ':'? (themeColor=ThemeColor | customColor=[CustomColor:CustomColorId]) ';'?;
705
+
706
+ OpacityProperty:
707
+ key='opacity' ':'? value=Percent ';'?;
708
+
709
+ // Element properties -------------------------------------
710
+ IconProperty:
711
+ key='icon' ':'? (libicon=[LibIcon:IconId] | value=('none'|Uri)) ';'?;
712
+
713
+ ShapeProperty:
714
+ key='shape' ':'? value=ElementShape ';'?;
715
+
716
+
717
+ BorderStyleValue returns string:
718
+ LineOptions | 'none';
719
+
720
+ BorderProperty:
721
+ key='border' ':'? value=BorderStyleValue ';'?;
722
+
723
+ StyleProperty:
724
+ ColorProperty |
725
+ ShapeProperty |
726
+ BorderProperty |
727
+ OpacityProperty |
728
+ IconProperty;
729
+
730
+ ElementStyleProperty:
731
+ key='style' '{'
732
+ props+=StyleProperty*
733
+ '}';
734
+
735
+
736
+ // -------------------------
737
+ // Relationship Style Properties
738
+ LineProperty:
739
+ key='line' ':'? value=LineOptions ';'?;
740
+ ArrowProperty:
741
+ key=('head' | 'tail') ':'? value=ArrowType ';'?;
742
+
743
+ RelationshipStyleProperty:
744
+ ColorProperty | LineProperty | ArrowProperty;
745
+
746
+ LineOptions returns string:
747
+ 'solid' |
748
+ 'dashed' |
749
+ 'dotted'
750
+ ;
751
+
752
+ ArrowType returns string:
753
+ 'none' |
754
+ 'normal' |
755
+ 'onormal' |
756
+ 'dot' |
757
+ 'odot' |
758
+ 'diamond' |
759
+ 'odiamond' |
760
+ 'crow' |
761
+ 'open' |
762
+ 'vee'
763
+ ;
764
+
765
+ ThemeColor returns string:
766
+ 'primary' | 'secondary' | 'muted' | 'slate' | 'blue' | 'indigo' | 'sky' | 'red' | 'gray' | 'green' | 'amber';
767
+ ElementShape returns string:
768
+ 'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
769
+
770
+ CustomColorValue returns string:
771
+ Hash (Id | Hex | Number);
772
+
773
+ IconId returns string:
774
+ LIB_ICON;
775
+
776
+ Uri returns string:
777
+ URI_WITH_SCHEMA | URI_RELATIVE;
778
+
779
+ TagId returns string:
780
+ Hash Id;
781
+
782
+ DotId returns string:
783
+ Dot Id;
784
+
785
+ CustomColorId returns string:
786
+ IdTerminal | ElementShape | ArrowType | LineOptions | 'element' | 'model';
787
+
788
+ Id returns string:
789
+ IdTerminal | ElementShape | ThemeColor | ArrowType | LineOptions | 'element' | 'model' | 'group' | 'node' | 'deployment' | 'instance';
790
+
791
+ fragment EqOperator:
792
+ (
793
+ operator=(Eq | NotEqual) |
794
+ operator="is" not?='not'?
795
+ )
796
+ ;
797
+
798
+ fragment IsEqual:
799
+ isEqual?=Eq | NotEqual;
800
+
801
+ // -----------------------------------
802
+ // Symbols
803
+ // terminal fragment HASH: '#';
804
+ // terminal fragment UNDERSCORE: '_';
805
+ // terminal fragment DASH: '-';
806
+ // terminal fragment LETTER: /[^\W\d_]/;
807
+ // terminal fragment DIGIT: /[0-9]/;
808
+ // terminal fragment NEWLINE: /[\r?\n]/;
809
+ // terminal fragment SPACE: /[^\S\r\n]/;
810
+
811
+ // -------------------------
812
+ // Comments
813
+ hidden terminal BLOCK_COMMENT: /\/\*[\s\S]*?\*\//;
814
+ hidden terminal LINE_COMMENT: /\/\/[^\n\r]*/;
815
+ hidden terminal WS: /[\t ]+/;
816
+ hidden terminal NL: /[\r\n]+/;
817
+
818
+ // -----------------------------------
819
+ // Terminals
820
+ //terminal LineStartWithDash: /(?<=([\r?\n][^\S\r\n]*))-/;
821
+
822
+ // LibIcons
823
+ terminal LIB_ICON: /(aws|azure|gcp|tech):[-\w]*/;
824
+
825
+ terminal URI_WITH_SCHEMA: /\w+:\/\/\S+/;
826
+ terminal URI_RELATIVE: /\.{0,2}\/[^\/]\S+/;
827
+
828
+ terminal DotUnderscore: /\b\._(?![_a-zA-Z])/;
829
+ terminal DotWildcard: /\b\.\*{1,2}/;
830
+ terminal Hash: '#';
831
+
832
+ // No space allowed before dot
833
+ terminal StickyDot: /\b\./;
834
+ terminal Dot: '.';
835
+ terminal NotEqual: /\!\={1,2}/;
836
+ terminal Eq: /\={1,2}/;
837
+ terminal Percent: /\b\d+%/;
838
+
839
+ terminal String: /"[^"]*"|'[^']*'/;
840
+
841
+ // terminal TagId: HASH LETTER (LETTER | DIGIT | UNDERSCORE | DASH)*;
842
+ // terminal IdTerminal: (LETTER | UNDERSCORE+ (LETTER | DIGIT)) (LETTER | DIGIT | UNDERSCORE | DASH)*;
843
+ terminal IdTerminal: /[_]*[a-zA-Z][-\w]*/;
844
+ terminal Number returns number: /\b\d+\b/;
845
+ terminal Hex: /\b[a-zA-Z0-9]+\b/;