39
39
/]
40
40
41
41
42
+ [**
43
+ * return the package output directory.
44
+ * property: packageDir
45
+ * default : .
46
+ */]
42
47
[query public getPackageDirectory( anPackage : EPackage ) : String =
43
48
let replacement : String = if anPackage.hasPackageProperty('packageDir')
44
49
then anPackage.getPackageProperty('packageDir')
45
50
else '$1' endif in
46
51
anPackage.name.replaceFirst('(.*)', replacement)
47
52
/]
48
53
54
+ [**
55
+ * return the package module resolution.
56
+ * property: moduleResolution
57
+ * default : nodenext
58
+ */]
49
59
[query public getModuleResolution(anPackage : EPackage) : String =
50
60
if anPackage.hasPackageProperty('moduleResolution')
51
61
then anPackage.getPackageProperty('moduleResolution').toLower()
52
62
else 'nodenext'
53
63
endif
54
64
/]
55
65
66
+ [**
67
+ * return the package test framework.
68
+ * property: testFramework
69
+ * default : jest
70
+ */]
56
71
[query public getTestFramework(anPackage : EPackage) : String =
57
72
if anPackage.hasPackageProperty('testFramework')
58
73
then anPackage.getPackageProperty('testFramework').toLower()
59
74
else 'jest'
60
75
endif
61
76
/]
62
77
78
+
79
+ [**
80
+ * return true if the package test framework is vitest
81
+ */]
63
82
[query public isVitest(anPackage : EPackage) : Boolean =
64
83
anPackage.getTestFramework() = 'vitest'
65
84
/]
75
94
else false
76
95
endif
77
96
/]
97
+
98
+ [**
99
+ * return the package accessors type for features.
100
+ * property: accessors
101
+ * default : method
102
+ */]
103
+ [query public getAccessorsType(aPackage : EPackage) : Sequence(String) =
104
+ if aPackage.hasPackageProperty('accessors') then
105
+ aPackage.getPackageProperty('accessors').tokenize(',')
106
+ else
107
+ Sequence{'method'}
108
+ endif
109
+ /]
110
+
111
+ [**
112
+ * return the accessors type for a feature.
113
+ * property: accessors
114
+ * default : method
115
+ */]
116
+ [query public getAccessorsType(aFeature : EStructuralFeature) : Sequence(String) =
117
+ if aFeature.hasKey('accessors') then
118
+ aFeature.valueKey('accessors').tokenize(',')
119
+ else
120
+ aFeature.getEPackage().getAccessorsType()
121
+ endif
122
+ /]
123
+
124
+ [**
125
+ * return true if feature accessors are defined as property
126
+ */]
127
+ [query public isPropertyAccessors(aFeature : EStructuralFeature) : Boolean =
128
+ aFeature.getAccessorsType()->includes('property')
129
+ /]
130
+
131
+ [**
132
+ * return true if feature accessors are defined as property
133
+ */]
134
+ [query public isMethodAccessors(aFeature : EStructuralFeature) : Boolean =
135
+ aFeature.getAccessorsType()->includes('method')
136
+ /]
137
+
138
+ [**
139
+ * return true if feature accessors are defined as async
140
+ */]
141
+ [query public isAsync(aPackage : EPackage) : Boolean =
142
+ if aPackage.hasPackageProperty('async') then
143
+ aPackage.getPackageProperty('async') = 'true'
144
+ else
145
+ false
146
+ endif
147
+ /]
148
+
149
+ [**
150
+ * return true if element accessors are defined as async
151
+ */]
152
+ [query public isAsync(aTypedElement : ETypedElement) : Boolean =
153
+ if aTypedElement.hasKey('async') then
154
+ aTypedElement.valueKey('async') = 'true'
155
+ else
156
+ aTypedElement.getEPackage().isAsync()
157
+ endif
158
+ /]
159
+
160
+
78
161
[**
79
162
* File Comments
80
163
*/]
85
168
[/template]
86
169
87
170
[query public hasExtension( aModelElement : EModelElement ) : Boolean = hasKey('extension') and valueKey('extension' )='true'/]
171
+
88
172
[query public isExported( aNamedElement : ENamedElement ) : Boolean = if ( hasKey('exported') ) then valueKey('exported') = 'true' else false endif/]
89
173
90
174
[**
@@ -183,10 +267,25 @@ endif endif endif endif
183
267
/]
184
268
185
269
[** Accessors Names **/]
186
- [query public getterPrefix(feature : EStructuralFeature) : String = if feature.eType.name = 'EBoolean' then 'Is' else 'Get' endif/]
270
+ [query private getterPrefix(feature : EStructuralFeature) : String =
271
+ if feature.eType.name = 'EBoolean' then
272
+ if feature.isPropertyAccessors() then
273
+ 'get'
274
+ else
275
+ 'is'
276
+ endif
277
+ else
278
+ 'get'
279
+ endif
280
+ /]
281
+
282
+ [query public getSetterName(feature : EStructuralFeature) : String = feature.getElementName( feature.name.toUpperFirst(), 'setterName', 'set$1')/]
283
+
284
+ [query public getGetterName(feature : EStructuralFeature) : String = feature.getElementName( feature.name.toUpperFirst(), 'getterName', feature.getterPrefix() + '$1')/]
187
285
188
- [query public getUnSetterName(feature : EStructuralFeature) : String = feature.getElementName( name.toUpperFirst() , 'unSetterName', 'unSet$1')/]
189
- [query public getIsSetName(feature : EStructuralFeature) : String = feature.getElementName( name.toUpperFirst() , 'isSetName', 'isSet$1')/]
286
+ [query public getUnSetterName(feature : EStructuralFeature) : String = feature.getElementName( feature.name.toUpperFirst(), 'unSetterName', 'unSet$1')/]
287
+
288
+ [query public getIsSetName(feature : EStructuralFeature) : String = feature.getElementName( feature.name.toUpperFirst(), 'isSetName', 'isSet$1')/]
190
289
191
290
[query public getOperationName(aOperation : EOperation ) : String = aOperation.getElementName( aOperation.name , 'operationName' )/]
192
291
@@ -197,6 +296,22 @@ endif endif endif endif
197
296
endif
198
297
/]
199
298
299
+ [query public getPropertyName( aFeature : EStructuralFeature ) : String =
300
+ if aFeature.eType.name = 'EBoolean' then
301
+ 'is' + aFeature.name.toUpperFirst()
302
+ else if getReservedKeywords()->exists(s | s = aFeature.name) then
303
+ aFeature.name + '_'
304
+ else
305
+ aFeature.name
306
+ endif endif/]
307
+
308
+ [query public getVariableName( aFeature : EStructuralFeature ) : String =
309
+ '_' + (if aFeature.eType.name = 'EBoolean' then
310
+ 'is' + aFeature.name.toUpperFirst()
311
+ else aFeature.name endif
312
+ )
313
+ /]
314
+
200
315
[query public getReflectiveGetterName(anENamedElement : ENamedElement) : String =
201
316
let getterName : String = 'get' + anENamedElement.getElementAccessorName() in
202
317
let ecorePackageClass : EClass = anENamedElement.eClass().ePackage.eClass() in
0 commit comments