-
Notifications
You must be signed in to change notification settings - Fork 14
/
uml2service.mtl
284 lines (224 loc) · 13.9 KB
/
uml2service.mtl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
[comment encoding = UTF-8 /]
[module uml2service('http://www.eclipse.org/uml2/5.0.0/UML')/]
[query public indexInContainer(class : Element) : Integer
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getIndexInContainer(org.eclipse.uml2.uml.Element)', Sequence{class})
/]
[query public hasStereotype(class : Element, name : String) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'hasStereotype(org.eclipse.uml2.uml.Element, java.lang.String)', Sequence{class, name})
/]
[query public getStereotype(class : Element, name : String) : Stereotype
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getStereotype(org.eclipse.uml2.uml.Element, java.lang.String)', Sequence{class, name})
/]
[query public getStereotypeValue(class : Element, name : String,propertyname : String) : OclAny
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getStereotypeValue(org.eclipse.uml2.uml.Element, java.lang.String, java.lang.String)', Sequence{class, name,propertyname})
/]
[query public getStereotypeListValue(class : Element, name : String,propertyname : String) : Sequence(Constraint)
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getStereotypeListValue(org.eclipse.uml2.uml.Element, java.lang.String, java.lang.String)', Sequence{class, name,propertyname})
/]
[query public getSolidityFileHeader(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getSolidityFileHeader(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getJsFileHeader(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getJsFileHeader(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getJsControllerDirectory(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getJsControllerDirectory(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateJsController(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateJsController(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getJsTestsDirectory(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getJsTestsDirectory(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateJsTests(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateJsTests(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getAbiDirectory(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getAbiDirectory(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateAbi(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateAbi(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getVersionPragma(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getVersionPragma(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public enableVersion(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'enableVersion(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateWeb3(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateWeb3(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public solidity2javaType(type : Type) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'solidity2javaType(org.eclipse.uml2.uml.Type)', Sequence{type})
/]
[query public getInterfacePackagePrefix(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getInterfacePackagePrefix(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getJavaTestDirectory(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getJavaTestDirectory(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateJavaTests(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateJavaTests(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public generateJavaNoneBlocking(class : NamedElement) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'generateJavaNoneBlocking(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getContractPathForJava(class : NamedElement) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getContractPathForJava(org.eclipse.uml2.uml.NamedElement)', Sequence{class})
/]
[query public getBooleanConfigurationParameter(class : NamedElement, parameterId : String) : Boolean
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getBooleanConfigurationParameter(org.eclipse.uml2.uml.NamedElement, java.lang.String)', Sequence{class, parameterId})
/]
[query public getConfigurationParameter(class : NamedElement, parameterId : String) : String
= invoke('de.urszeidler.eclipse.solidity.util.Uml2Service', 'getConfigurationParameter(org.eclipse.uml2.uml.NamedElement, java.lang.String)', Sequence{class, parameterId})
/]
[query public hasSuperTypes(aClass : Class) : Boolean =
not self.allSuperTypesWithoutContractApi()->isEmpty() /]
[query public isGeneratePackage(pa : Package) : Boolean =
not pa.allContracts()->isEmpty()
or not pa.allLibrarys()->isEmpty()
or not pa.allInterfaces()->isEmpty()
/]
[query public allContracts(aModel : Model) : OrderedSet(Class) = aModel.ownedElement
->selectByType(Class)
->select(hasStereotype('Contract'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allContracts(aModel : Package) : OrderedSet(Class) = aModel.ownedElement
->selectByType(Class)
->select(hasStereotype('Contract'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allInterfaces(aModel : Model) : OrderedSet(Interface) = aModel.ownedElement
->selectByType(Interface)
->sortedBy( indexInContainer(oclAsType(Interface)) ) /]
[query public allInterfaces(aModel : Package) : OrderedSet(Interface) = aModel.ownedElement
->selectByType(Interface)
->sortedBy( indexInContainer(oclAsType(Interface)) ) /]
[query public allLibrarys(aModel : Model) : OrderedSet(Class) = aModel.ownedElement
->selectByType(Class)
->select(hasStereotype('Library'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allLibrarys(aModel : Package) : OrderedSet(Class) = aModel.ownedElement
->selectByType(Class)
->select(hasStereotype('Library'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allStructs(aClass : Class) : OrderedSet(Class) = aClass.ownedMember
->select(hasStereotype('Struct'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allStructs(aClass : Interface) : OrderedSet(Class) = aClass.ownedMember
->select(hasStereotype('Struct'))
->sortedBy( indexInContainer(oclAsType(Class)) ) /]
[query public allFunctions(aClass : Class) : OrderedSet(Operation) = aClass.allOwnedElements()
->selectByType(Operation)
->select(hasStereotype('Function'))
->sortedBy(indexInContainer(oclAsType(Operation))) /]
[query public allConstructors(aClass : Class) : OrderedSet(Operation) = aClass.allOwnedElements()
->selectByType(Operation)
->select(hasStereotype('Constructor'))
->sortedBy(indexInContainer(oclAsType(Operation))) /]
[query public allAbstractFunctions(aClass : Class) : Sequence(Operation) = aClass.allSuperTypes()
->collect(ownedElement)
->selectByKind(Operation)
->select(hasStereotype('Function'))
->select(owner.oclIsTypeOf(Interface) or isAbstract)
->sortedBy(indexInContainer(oclAsType(Operation))) /]
[query public allAbstractFunctions1(aClass : Class) : OrderedSet(Operation) = aClass.getAllOperations()
->selectByType(Operation)
->select(hasStereotype('Function'))
->select(owner.oclIsTypeOf(Interface) or isAbstract)
->select( aClass.allSuperTypes()->includes(owner) )
->sortedBy(indexInContainer(oclAsType(Operation))) /]
[query public allSubFunctions(aClass : Class) : OrderedSet(Operation) = aClass.getAllOperations()
->select(hasStereotype('Function'))
->select(visibility<>VisibilityKind::private)
->sortedBy(indexInContainer(oclAsType(Operation)) + name )
/]
[query public allSubAttributes(aClass : Class) : OrderedSet(Property) = aClass.allAttributes()
->select(not hasStereotype('Mapping') and not hasStereotype('KeyMapping'))
->select(isPublic())
->sortedBy(indexInContainer(oclAsType(Property)) + name )
/]
[query public allMappingSubAttributes(aClass : Class) : OrderedSet(Property) = aClass.allAttributes()
->select(hasStereotype('Mapping'))
->select(isPublic())
->sortedBy(indexInContainer(oclAsType(Property)) + name )
/]
[query public allKeyMappingSubAttributes(aClass : Class) : OrderedSet(Property) = aClass.allAttributes()
->select(hasStereotype('KeyMapping'))
->select(isPublic())
->sortedBy(indexInContainer(oclAsType(Property)) + name )
/]
[query public allEvents(aClass : Class) : OrderedSet(Operation) = aClass.ownedOperation->select(isEvent()) /]
[query public hasEvents(aClass : Class) : Boolean = not aClass.allEvents()->isEmpty() /]
[query public isAbstractContract(aClass : Class) : Boolean = aClass.isContract() and not aClass.allFunctions()-> select(isAbstract)->isEmpty() /]
[query public isPrivate(p : Property) : Boolean = p.visibility=VisibilityKind::private /]
[query public isPublic(p : Property) : Boolean = p.visibility.oclIsUndefined() or p.visibility=VisibilityKind::public /]
[query public isPublic(f : Operation) : Boolean = f.visibility.oclIsUndefined() or f.visibility=VisibilityKind::public /]
[query public isMapping(p : Property) : Boolean = p.hasStereotype('Mapping') /]
[query public isKeyMapping(p : Property) : Boolean = p.hasStereotype('KeyMapping') /]
[query public isAttribute(p : Property) : Boolean = not p.hasStereotype('Mapping') and not p.hasStereotype('KeyMapping')/]
[query public isContract(c : Type) : Boolean = c.hasStereotype('Contract') /]
[query public isStruct(s : Type) : Boolean = s.hasStereotype('Struct') /]
[query public isFunction(s : Operation) : Boolean = s.hasStereotype('Function') /]
[query public isEvent(s : Operation) : Boolean = s.hasStereotype('Event') /]
[query public isPayable(op : Operation) : Boolean = not op.getStereotypeListValue('Function','modifiers')->select(isPayable())->isEmpty() /]
[query public isDefaultFunction(f : Operation) : Boolean = f.name.isEmpty() /]
[query public isPayable(d : OclAny) : Boolean = if d.eGet('modifier').oclIsUndefined() then false
else
d.eGet('modifier').eGet('qualifiedName')='types::lang::payable'
endif
/]
[query public isIndexed(s : Parameter) : Boolean = s.hasStereotype('Indexed') /]
[query public allCProperties(c : Class) : OrderedSet(Property) = c.attribute
-> select(not hasStereotype('Mapping') and not hasStereotype('KeyMapping')) /]
[query public allMappingProperties(c : Class) : OrderedSet(Property) = c.attribute
-> select(isMapping()) /]
[query public allKeyMappingProperties(c : Class) : OrderedSet(Property) = c.attribute
-> select(isKeyMapping()) /]
[query public allGetterProperties(c : Class) : OrderedSet(Property) = c.attribute
-> select(hasStereotype('GetterSetter')) /]
[query public allSuperTypes(aClass : Class) : Sequence(Classifier) = aClass.general
->union(aClass.interfaceRealization->collect(contract))
->sortedBy( indexInContainer(oclAsType(Classifier)) ) /]
[query public allSuperTypesWithoutContractApi(aClass : Class) : Sequence(Classifier) = aClass.allSuperTypes()
->select(not hasStereotype('StandardizedContractAPI'))
->sortedBy( indexInContainer(oclAsType(Classifier))+name ) /]
[query public allInParameters(aOp : Operation) : OrderedSet(Parameter) = aOp.ownedParameter->
select(oclAsType(Parameter).direction=ParameterDirectionKind::_in) /]
[query public allReturnParameters(aOp : Operation) : OrderedSet(Parameter) = aOp.ownedParameter->
select(oclAsType(Parameter).direction=ParameterDirectionKind::return) /]
[query public hasReturnValue(aOperation : Operation) : Boolean = aOperation.allReturnParameters()->size()>0 /]
[query public inherites(aClass : Class,superE : Element) : Boolean = not aClass.allSuperTypes()->includes(superE) /]
[query public hasModifier(aOperation : Operation) : Boolean = not aOperation.allModifier()->isEmpty() or not aOperation.allParameterModifier()->isEmpty() /]
[query public isReturnConstant(aOperation : Operation) : Boolean = aOperation.hasReturnValue()
and aOperation.getStereotypeValue('Function', 'returnType').oclAsType(NamedElement).name<>'default' /]
[query public allModifier(op : Operation) : Set(Constraint) = Constraint.allInstances()->select(constrainedElement->includes(op))
/]
[query public allParameterModifier(op : Operation) : Set(DataType) = op.getStereotypeListValue('Function','modifiers')->asSet()
/]
[query public appliedModifier(op : Operation) : Sequence(Constraint) =
op.getStereotypeListValue('Function','modifier')
/]
[query public allImports(p : Package) : OrderedSet(PackageImport) = p.packageImport
->select(hasStereotype('Import'))
->sortedBy(indexInContainer(oclAsType(PackageImport)))
/]
[template public operationParameters(op : Operation)]
[for (p : Parameter | op.allInParameters())]_[p.type.name/][/for]
[/template]
[template public operationReturnParameters(op : Operation)]
[for (p : Parameter | op.allReturnParameters())]_[p.type.name/][/for]
[/template]
[template public printLines(aString : String, prefix : String)]
[for (line : String | aString.tokenizeLine())]
[prefix/] [line/]
[/for]
[/template]
[**
* Prints the string in one line seperated with ' '.
*/]
[template public printInLines(aString : String)]
[for (line : String | aString.tokenizeLine())separator (' ')]
[line/][/for]
[/template]
[query public isEmpty(s : String) : Boolean = s.oclIsUndefined() or s='' /]
[comment][query public firstReturnParameter(aOperation : Operation) : Parameter = aOperation.ownedParameter->select(oclAsType(Parameter).direction=ParameterDirectionKind::return)->first() /][/comment]