@@ -55,12 +55,12 @@ final class WrapperGenerator {
5555 if (! isEmpty(ePackage)) {
5656 createFolder(PATH . append(WRAPPER_FOLDER , path))
5757 }
58- for (EClassifier eClassifier : ePackage. EClassifiers ) { // for every classifier
58+ for (eClassifier : ePackage. EClassifiers ) { // for every classifier
5959 if (eClassifier instanceof EClass ) { // if is class
60- createXtendWrapper(path, eClassifier. getName) // create wrapper class
60+ createXtendWrapper(path, eClassifier. getName, getSuperClass(eClassifier) ) // create wrapper class
6161 }
6262 }
63- for (EPackage eSubpackage : ePackage. ESubpackages ) { // for every subpackage
63+ for (eSubpackage : ePackage. ESubpackages ) { // for every subpackage
6464 buildWrappers(eSubpackage, PATH . append(path, eSubpackage. getName)) // do the same
6565 }
6666 }
@@ -78,11 +78,11 @@ final class WrapperGenerator {
7878 /**
7979 * Creates a Xtend Wrapper in a package path with a specific name.
8080 */
81- def private static void createXtendWrapper (String packagePath , String name ) {
81+ def private static void createXtendWrapper (String packagePath , String name , String superClass ) {
8282 val currentPackage = packagePath. replace(File . separatorChar, ' .' )
8383 var factoryName = ' ' ' «PACKAGE.nameOf(currentPackage)»Factory' ' '
8484 factoryName = factoryName. substring(0 , 1 ). toUpperCase + factoryName. substring(1 ) // first letter upper case
85- val content = wrapperContent(name, factoryName, currentPackage)
85+ val content = wrapperContent(name, factoryName, currentPackage, superClass )
8686 createFile(packagePath, ' ' ' «name»Wrapper.xtend' ' ' , content)
8787 }
8888
@@ -98,6 +98,28 @@ final class WrapperGenerator {
9898 file. touch(MONITOR )
9999 }
100100 }
101+
102+ def private static String getSuperClass (EClass eClass ) {
103+ for (superType : eClass. ESuperTypes ) {
104+ if (! superType. interface) {
105+ System . err. println(" ECLASS " + eClass. name + " IS " +
106+ PACKAGE . append(getPackage(superType), superType. name)) // TODO
107+ return PACKAGE . append(getPackage(superType), superType. name)
108+ }
109+ }
110+ return null
111+ }
112+
113+ def private static String getPackage (EClass eClass ) {
114+ var String package = " "
115+ var EPackage current = eClass. EPackage
116+ while (current !== null ) {
117+ package = PACKAGE . append(current. name, package )
118+ current = current. ESuperPackage
119+ }
120+ System . err. println(" PACKAGE OF " + eClass. name + " IS " + package ) // TODO
121+ return PACKAGE . cutParent(package )
122+ }
101123
102124 /**
103125 * Checks whether the EPackage is empty or not. An empty ePackage has no classifiers and only empty subpackages.
@@ -116,17 +138,21 @@ final class WrapperGenerator {
116138 /**
117139 * Builds the content of a wrapper class.
118140 */
119- def private static String wrapperContent (String className , String factoryName , String currentPackage ) '''
141+ def private static String wrapperContent (String className , String factoryName , String currentPackage ,
142+ String superClass ) '''
120143 package «PACKAGE.append ("wrappers ", currentPackage )»
121144
122145 import org.eclipse.xtend.lib.annotations.Delegate
123146 import «PACKAGE.append ("ecore ", currentPackage )».«className»
124147 import «PACKAGE.append ("ecore ", currentPackage )».«factoryName»
148+ «IF superClass !== null»
149+ import «superClass»
150+ «ENDIF»
125151
126152 /**
127153 * Wrapper class for the class «className»
128154 */
129- class «className»Wrapper implements «className» {
155+ class «className»Wrapper«IF superClass !== null» extends «PACKAGE. nameOf ( superClass )»«ENDIF» implements «className» {
130156 @Delegate
131157 private var «className» ecoreImplementation
132158
0 commit comments