16
16
17
17
package org.modelix.model.api
18
18
19
- import kotlin.reflect.KProperty
20
-
21
19
/* *
22
20
* TODO if you add a new Concept to a language, do not forget to add it to the language's included concepts field.
23
21
* Otherwise the concept will not be eagerly added to the Language, when registering the language in the ILanguageRegistry.
@@ -43,8 +41,13 @@ object BuiltinLanguages {
43
41
uid = " ceab5195-25ea-4f22-9b92-103b95ca8c0c/1133920641626/1193676396447" ,
44
42
).also (this ::addProperty)
45
43
46
- val smodelAttribute by childLink(" ceab5195-25ea-4f22-9b92-103b95ca8c0c/1133920641626/5169995583184591170" ).multiple()
47
- .optional().type { Attribute }
44
+ val smodelAttribute = SimpleChildLink (
45
+ simpleName = " smodelAttribute" ,
46
+ isMultiple = true ,
47
+ isOptional = true ,
48
+ targetConcept = Attribute ,
49
+ uid = " ceab5195-25ea-4f22-9b92-103b95ca8c0c/1133920641626/5169995583184591170" ,
50
+ ).also (this ::addChildLink)
48
51
}
49
52
50
53
object Attribute : SimpleConcept(
@@ -111,21 +114,23 @@ object BuiltinLanguages {
111
114
isOptional = true ,
112
115
targetConcept = jetbrains_mps_lang_core.BaseConcept ,
113
116
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618892/474657388638618900" ,
114
- )
117
+ ).also (this ::addChildLink)
118
+
115
119
val modelImports = SimpleChildLink (
116
120
simpleName = " modelImports" ,
117
121
isMultiple = true ,
118
122
isOptional = true ,
119
123
targetConcept = ModelReference ,
120
124
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618892/6402965165736931000" ,
121
- )
125
+ ).also (this ::addChildLink)
126
+
122
127
val usedLanguages = SimpleChildLink (
123
128
simpleName = " usedLanguages" ,
124
129
isMultiple = true ,
125
130
isOptional = true ,
126
131
targetConcept = SingleLanguageDependency ,
127
132
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618892/5381564949800872334" ,
128
- )
133
+ ). also ( this ::addChildLink)
129
134
}
130
135
131
136
object Module : SimpleConcept(
@@ -156,28 +161,31 @@ object BuiltinLanguages {
156
161
isOptional = true ,
157
162
targetConcept = Model ,
158
163
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618895/474657388638618898" ,
159
- )
164
+ ).also (this ::addChildLink)
165
+
160
166
val facets = SimpleChildLink (
161
167
simpleName = " facets" ,
162
168
isMultiple = true ,
163
169
isOptional = true ,
164
170
targetConcept = ModuleFacet ,
165
171
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618895/2206727074858242412" ,
166
- )
172
+ ).also (this ::addChildLink)
173
+
167
174
val dependencies = SimpleChildLink (
168
175
simpleName = " dependencies" ,
169
176
isMultiple = true ,
170
177
isOptional = true ,
171
178
targetConcept = ModuleDependency ,
172
179
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618895/2206727074858242425" ,
173
- )
180
+ ).also (this ::addChildLink)
181
+
174
182
val languageDependencies = SimpleChildLink (
175
183
simpleName = " languageDependencies" ,
176
184
isMultiple = true ,
177
185
isOptional = true ,
178
186
targetConcept = LanguageDependency ,
179
187
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618895/2206727074858242439" ,
180
- )
188
+ ). also ( this ::addChildLink)
181
189
}
182
190
183
191
object Solution : SimpleConcept(
@@ -217,23 +225,23 @@ object BuiltinLanguages {
217
225
isOptional = true ,
218
226
targetConcept = Module ,
219
227
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618902/474657388638618903" ,
220
- )
228
+ ). also ( this ::addChildLink)
221
229
222
230
val projects = SimpleChildLink (
223
231
simpleName = " projects" ,
224
232
isMultiple = true ,
225
233
isOptional = true ,
226
234
targetConcept = Project ,
227
235
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618902/7064605579395546636" ,
228
- )
236
+ ). also ( this ::addChildLink)
229
237
230
238
val tempModules = SimpleChildLink (
231
239
simpleName = " tempModules" ,
232
240
isMultiple = true ,
233
241
isOptional = true ,
234
242
targetConcept = Module ,
235
243
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/474657388638618902/8226136427470548682" ,
236
- )
244
+ ). also ( this ::addChildLink)
237
245
}
238
246
239
247
object Project : SimpleConcept(
@@ -249,15 +257,15 @@ object BuiltinLanguages {
249
257
isOptional = true ,
250
258
targetConcept = Module ,
251
259
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/4008363636171860313/4008363636171860450" ,
252
- )
260
+ ). also ( this ::addChildLink)
253
261
254
262
val projectModules = SimpleChildLink (
255
263
simpleName = " projectModules" ,
256
264
isMultiple = true ,
257
265
isOptional = true ,
258
266
targetConcept = ProjectModule ,
259
267
uid = " 0a7577d1-d4e5-431d-98b1-fae38f9aee80/4008363636171860313/4201834143491306088" ,
260
- )
268
+ ). also ( this ::addChildLink)
261
269
}
262
270
263
271
object ProjectModule : SimpleConcept(
@@ -426,7 +434,7 @@ object BuiltinLanguages {
426
434
isOptional = true ,
427
435
targetConcept = RepositoryInfo ,
428
436
uid = " b6980ebd-f01d-459d-a952-38740f6313b4/7113393488488348863/7113393488488348866" ,
429
- )
437
+ ). also ( this ::addChildLink)
430
438
}
431
439
432
440
object RepositoryInfo : SimpleConcept(
@@ -447,7 +455,7 @@ object BuiltinLanguages {
447
455
isOptional = true ,
448
456
targetConcept = BranchInfo ,
449
457
uid = " b6980ebd-f01d-459d-a952-38740f6313b4/7113393488488348864/7113393488488348868" ,
450
- )
458
+ ). also ( this ::addChildLink)
451
459
}
452
460
453
461
object BranchInfo : SimpleConcept(
@@ -465,32 +473,3 @@ object BuiltinLanguages {
465
473
ModelixRuntimelang ,
466
474
)
467
475
}
468
-
469
- private fun SimpleConcept.childLink (uid : String ) = object {
470
- private lateinit var name: String
471
- private lateinit var owner: SimpleConcept
472
- private var multiple: Boolean = true
473
- private var optional: Boolean = true
474
- private lateinit var targetConcept: () -> IConcept
475
- private val instance: IChildLink by lazy {
476
- SimpleChildLink (
477
- simpleName = name,
478
- uid = uid,
479
- isMultiple = multiple,
480
- isOptional = optional,
481
- targetConcept = targetConcept(),
482
- ).also { owner.addChildLink(it) }
483
- }
484
-
485
- operator fun getValue (ownerConcept : SimpleConcept , kotlinProperty : KProperty <* >): IChildLink {
486
- this .owner = ownerConcept
487
- this .name = kotlinProperty.name
488
- return instance
489
- }
490
-
491
- fun mandatory () = this .also { this .optional = false }
492
- fun optional () = this .also { this .optional = true }
493
- fun single () = this .also { this .multiple = false }
494
- fun multiple () = this .also { this .multiple = true }
495
- fun type (targetConcept : () -> IConcept ) = also { this .targetConcept = targetConcept }
496
- }
0 commit comments