/
Example.java
52 lines (44 loc) · 1.69 KB
/
Example.java
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
package com.example;
import edelta.lib.AbstractEdelta;
import gssi.refactorings.MMrefactorings;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@SuppressWarnings("all")
public class Example extends AbstractEdelta {
private MMrefactorings refactorings;
public Example() {
refactorings = new MMrefactorings(this);
}
public Example(final AbstractEdelta other) {
super(other);
}
public EClass createClass(final String name) {
EClass _newEClass = this.lib.newEClass(name);
final Procedure1<EClass> _function = new Procedure1<EClass>() {
public void apply(final EClass it) {
EList<EClass> _eSuperTypes = it.getESuperTypes();
_eSuperTypes.add(getEClass("myecore", "MyEClass"));
}
};
return ObjectExtensions.<EClass>operator_doubleArrow(_newEClass, _function);
}
@Override
public void performSanityChecks() throws Exception {
ensureEPackageIsLoaded("myecore");
ensureEPackageIsLoaded("ecore");
}
@Override
protected void doExecute() throws Exception {
createEClass("myecore", "MyNewClass", createList(this::_createEClass_MyNewClass_in_myecore));
}
public void _createEClass_MyNewClass_in_myecore(final EClass it) {
{
this.refactorings.addMandatoryAttr(it, "ANewAttribute", getEDataType("ecore", "EString"));
getEAttribute("myecore", "MyNewClass", "ANewAttribute").setEType(getEDataType("ecore", "EInt"));
this.lib.addEClass(it.getEPackage(), this.createClass("ANewDerivedEClass"));
getEClass("myecore", "ANewDerivedEClass").setAbstract(true);
}
}
}