Commit 16e87186 authored by Marco Konersmann's avatar Marco Konersmann

Fixes code generation for the implemented of the mechanisms. These are just examples.

parent 957dda4d
Pipeline #3080 failed with stages
in 1 minute 21 seconds
......@@ -66,18 +66,18 @@ abstract class ClassMechanism extends Mechanism {
def createCrossReferencesTrasformations() {
return '''
@Override
public void doCreateCrossReferencesTransformations(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
«IF !eClass.EReferences.isEmpty»
// Child transformations for cross references
«FOR feature : eClass.EReferences»
«IF !(feature as EReference).isContainment»
result.add(new «feature.name.toFirstUpper»Transformation(this));
«ENDIF»
«ENDFOR»
«ENDIF»
}''';
@Override
public void doCreateCrossReferencesTransformations(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
«IF !eClass.EReferences.isEmpty»
// Child transformations for cross references
«FOR feature : eClass.EReferences»
«IF !(feature as EReference).isContainment»
result.add(new «feature.name.toFirstUpper»Transformation(this));
«ENDIF»
«ENDFOR»
«ENDIF»
}''';
}
def boolean requiresFeaturePackageImport(EClass eClass) {
......@@ -166,4 +166,14 @@ abstract class ClassMechanism extends Mechanism {
'''
}
def String createImportsForTargetTransformations() {
return '''
«IF !eClass.EStructuralFeatures.isEmpty»
«FOR feature : eClass.EStructuralFeatures»
import org.codeling.lang.«languageName».transformation.«eClass.name.toFirstLower»_feature.«feature»Transformation;
«ENDFOR»
«ENDIF»
'''
}
}
......@@ -35,15 +35,18 @@ class ConstantMemberAttributeMechanism extends AttributeMechanism {
}
override createRuntime(IPackageFragment packageFragment, ENamedElement element) {
var String typeName = element.name.toFirstUpper;
val String typeName = element.name.toFirstUpper;
val String targetTypeName = (element as EAttribute).EType.name;
val content = '''
package «packageFragment.elementName»;
import constant_member_attribute.runtime.ConstantMemberAttributeRuntime;
public class «typeName»Runtime extends ConstantMemberAttributeRuntime {
public «typeName»Runtime(TypeMechanismRuntime owningRuntime) {
super(owningRuntime, «typeName».class, «targetTypeName»Runtime.class);
}
}
''';
......@@ -60,14 +63,14 @@ class ConstantMemberAttributeMechanism extends AttributeMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.ConstantMemberAttributeTransformation;
import org.codeling.mechanisms.transformations.attributes.ConstantMemberAttributeTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.lang.«languageName».mm.«eAttribute.packageName».«eAttribute.packageName.toFirstUpper»Package;
import org.codeling.lang.«languageName».mm.«eAttribute.packageName».«eAttribute.EContainingClass.name»;
import «eAttribute.packageName».«eAttribute.packageName.toFirstUpper»Package;
import «eAttribute.packageName».«eAttribute.EContainingClass.name»;
public class «typeName»Transformation
extends ConstantMemberAttributeTransformation<«eAttribute.EContainingClass.name»> {
......@@ -83,9 +86,9 @@ class ConstantMemberAttributeMechanism extends AttributeMechanism {
}
@Override
protected ClassMechanismTransformation<? extends EObject, ? extends IJavaElement> createSpecificTransformation(
EObject targetModelElement) {
new «eAttribute.EType.name»Transformation(this);
protected void doCreateChildTransformationsToCode(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
// TODO Auto-generated method stub
}
@Override
......
......@@ -37,7 +37,7 @@ class ContainmentOperationMechanism extends ClassMechanism {
val content = '''
package «packageFragment.elementName»;
import org.codeling.lang.«languageName».mm.«owningElementName.toLowerCase»_feature.«typeName»;
import «languageName».mm.«owningElementName.toLowerCase»_feature.«typeName»;
import org.codeling.mechanism.runtime.ContainmentOperationRuntime;
import org.codeling.mechanism.runtime.common.IntegratedModelException;
import org.codeling.mechanism.runtime.common.TypeMechanismRuntime;
......@@ -90,14 +90,14 @@ class ContainmentOperationMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.ContainmentOperationTransformation;
import org.codeling.mechanisms.transformations.classes.ContainmentOperationTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.packageName»Package;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.packageName»Package;
import «eReference.packageName».«eReference.EContainingClass.name»;
public class «typeName»Transformation
extends ContainmentOperationTransformation<«eReference.EContainingClass.name», «eReference.EType.name»> {
......
......@@ -81,14 +81,14 @@ class MarkerInterfaceMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.MarkerInterfaceTransformation;
import org.codeling.mechanisms.transformations.classes.MarkerInterfaceTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.CodelingException;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.packageName»Package;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.name»;
import «eClass.packageName».«eClass.packageName»Package;
import «eClass.packageName».«eClass.name»;
«IF eClass.requiresFeaturePackageImport»
......
......@@ -68,14 +68,15 @@ class NinjaSingletonMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.NinjaSingletonTransformation;
import org.codeling.mechanisms.transformations.classes.NinjaSingletonTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.CodelingException;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.packageName»Package;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.name»;
«createImportsForTargetTransformations»
import «eClass.packageName».«eClass.packageName»Package;
import «eClass.packageName».«eClass.name»;
«IF eClass.requiresFeaturePackageImport»
......
......@@ -29,14 +29,15 @@ class ProjectMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.MarkerInterfaceTransformation;
import org.codeling.mechanisms.transformations.classes.MarkerInterfaceTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.CodelingException;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.packageName»Package;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.name»;
«createImportsForTargetTransformations»
import «eClass.packageName».«eClass.packageName»Package;
import «eClass.packageName».«eClass.name»;
«IF eClass.requiresFeaturePackageImport»
......
......@@ -42,14 +42,14 @@ class StaticInterfaceMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.StaticInterfaceTransformation;
import org.codeling.mechanisms.transformations.classes.StaticInterfaceTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.CodelingException;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.packageName»Package;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.name»;
import «eClass.packageName».«eClass.packageName»Package;
import «eClass.packageName».«eClass.name»;
«IF eClass.requiresFeaturePackageImport»
......
......@@ -89,15 +89,19 @@ class TypeAnnotationMechanism extends ClassMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.TypeAnnotationTransformation;
import org.codeling.mechanisms.transformations.classes.TypeAnnotationTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.CodelingException;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.packageName»Package;
import org.codeling.lang.«languageName».mm.«eClass.packageName».«eClass.name»;
import «eClass.packageName».«eClass.packageName»Package;
import «eClass.packageName».«eClass.name»;
import org.codeling.lang.«languageName».transformation.component_feature.VersionTransformation;
«IF eClass.requiresFeaturePackageImport»
import «packageFragment.elementName».«typeName.toLowerCase»_feature.*;
«ENDIF»
public class «typeName»Transformation
extends TypeAnnotationTransformation<«eClassName»> {
......@@ -115,7 +119,7 @@ class TypeAnnotationMechanism extends ClassMechanism {
packageFragment.createCompilationUnit('''«typeName»Transformation.java''', content, true, monitor);
}
override canHandle(IJavaElement codeElement, ENamedElement metaModelElement) {
return codeElement instanceof IType && (codeElement as IType).getAnnotation(metaModelElement.name).exists;
}
......
......@@ -33,15 +33,17 @@ class NinjaSingletonContainmentReferenceMechanism extends ContainmentMechanism {
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.packageName»Package;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EContainingClass.name»;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EType.name»;
import org.codeling.lang.«languageName».transformation.«eReference.EType.name»Transformation;
import org.codeling.mechanisms.transformations.NinjaSingletonContainmentTransformation;
import «eReference.packageName».«eReference.packageName»Package;
import «eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.EType.name»;
import «languageName».transformation.«eReference.EType.name»Transformation;
import org.codeling.mechanisms.transformations.references.NinjaSingletonContainmentTransformation;
import org.codeling.lang.base.java.ASTUtils;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.utils.Models;
import org.codeling.mechanisms.transformations.ClassMechanismTransformation;
import org.codeling.lang.«languageName».transformation.«eReference.EType.name»Transformation;
public class «typeName»Transformation extends NinjaSingletonContainmentTransformation<«eReference.EContainingClass.name», «eReference.EType.name»> {
......@@ -59,7 +61,7 @@ class NinjaSingletonContainmentReferenceMechanism extends ContainmentMechanism {
@Override
protected ClassMechanismTransformation<? extends EObject, ? extends IJavaElement> createSpecificTransformation(
EObject targetModelElement) {
new «eReference.EType.name»Transformation(this);
return new «eReference.EType.name»Transformation(this);
}
@Override
......
......@@ -50,8 +50,8 @@ class AnnotatedMemberReferenceMechanism extends ReferenceMechanism {
val content = '''
package «packageFragment.elementName»;
import org.codeling.lang.«languageName».mm.«owningElementName.toLowerCase»_feature.«typeName»;
import org.codeling.lang.ejbWithStatemachine.runtime.StateRuntime;
import «languageName».mm.«owningElementName.toLowerCase»_feature.«typeName»;
import org.codeling.lang.«languageName».runtime.«targetTypeName»Runtime;
import org.codeling.mechanism.runtime.AnnotatedMemberReferenceRuntime;
import org.codeling.mechanism.runtime.common.TypeMechanismRuntime;
......@@ -78,16 +78,18 @@ class AnnotatedMemberReferenceMechanism extends ReferenceMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.AnnotatedMemberReferenceTransformation;
import org.codeling.mechanisms.transformations.references.AnnotatedMemberReferenceTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.packageName»Package;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EContainingClass.name»;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EType.name»;
import «eReference.packageName».«eReference.packageName»Package;
import «eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.EType.name»;
import org.codeling.mechanisms.transformations.ClassMechanismTransformation;
import org.codeling.lang.«languageName».transformation.«eReference.EType.name»Transformation;
public class «typeName»Transformation
extends AnnotatedMemberReferenceTransformation<«eReference.EContainingClass.name», «eReference.EType.name»> {
......@@ -102,9 +104,9 @@ class AnnotatedMemberReferenceMechanism extends ReferenceMechanism {
}
@Override
protected void doCreateChildTransformationsToCode(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
// TODO Auto-generated method stub
protected ClassMechanismTransformation<? extends EObject, ? extends IJavaElement> createSpecificTransformation(
EObject targetModelElement) {
return new «eReference.EType.name»Transformation(this);
}
@Override
......
......@@ -65,14 +65,16 @@ class ContainmentOperationReferenceMechanism extends ReferenceMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.ReferenceParameterTransformation;
import org.codeling.mechanisms.transformations.references.ReferenceParameterTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.packageName»Package;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.packageName»Package;
import «eReference.packageName».«eReference.EContainingClass.name»;
import org.codeling.mechanisms.transformations.ClassMechanismTransformation;
import org.codeling.lang.«languageName».transformation.«eReference.EType.name»Transformation;
public class «typeName»Transformation
extends ReferenceParameterTransformation<«eReference.EContainingClass.name», «eReference.EType.name»> {
......@@ -88,9 +90,9 @@ class ContainmentOperationReferenceMechanism extends ReferenceMechanism {
}
@Override
protected void doCreateChildTransformationsToCode(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
// TODO Auto-generated method stub
protected ClassMechanismTransformation<? extends EObject, ? extends IJavaElement> createSpecificTransformation(
EObject targetModelElement) {
return new «eReference.EType.name»Transformation(this);
}
@Override
......
......@@ -17,6 +17,7 @@ class StaticInterfaceImplementationMechanism extends ReferenceMechanism {
}
override createRuntime(IPackageFragment packageFragment, ENamedElement element) {
}
override createTransformation(IPackageFragment packageFragment, ENamedElement element) {
......@@ -30,19 +31,22 @@ class StaticInterfaceImplementationMechanism extends ReferenceMechanism {
import java.util.List;
import org.codeling.mechanisms.transformations.StaticInterfaceImplementationTransformation;
import org.codeling.mechanisms.transformations.references.StaticInterfaceImplementationTransformation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.codeling.lang.base.java.transformation.AbstractModelCodeTransformation;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.packageName»Package;
import org.codeling.lang.«languageName».mm.«eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.packageName»Package;
import «eReference.packageName».«eReference.EContainingClass.name»;
import «eReference.packageName».«eReference.EType.name»;
import org.codeling.mechanisms.transformations.ClassMechanismTransformation;
import org.codeling.lang.«languageName».transformation.«eReference.EType.name»Transformation;
public class «typeName»Transformation
extends StaticInterfaceImplementationTransformation<«eReference.EContainingClass.name», «eReference.EType.name»> {
public «typeName»Transformation(AbstractModelCodeTransformation<? extends EObject, IType> parentTransformation) {
public «typeName»Transformation(ClassMechanismTransformation<«eReference.EContainingClass.name», IType> parentTransformation) {
super(parentTransformation, «eReferenceInstantiation»);
}
......@@ -53,9 +57,9 @@ class StaticInterfaceImplementationMechanism extends ReferenceMechanism {
}
@Override
protected void doCreateChildTransformationsToCode(
List<AbstractModelCodeTransformation<? extends EObject, ? extends IJavaElement>> result) {
// TODO Auto-generated method stub
protected ClassMechanismTransformation<? extends EObject, ? extends IJavaElement> createSpecificTransformation(
EObject targetModelElement) {
return new «eReference.EType.name»Transformation(this);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment