Beispiel #1
0
 public void generateBodyAnnotations(final XPackage pack) {
   final HashSet<ETypedElement> processed = CollectionLiterals.<ETypedElement>newHashSet();
   EList<XClassifier> _classifiers = pack.getClassifiers();
   for (final XClassifier xClassifier : _classifiers) {
     if ((xClassifier instanceof XDataType)) {
       final XDataType xDataType = ((XDataType) xClassifier);
       XDataTypeMapping _mapping = this.mappings.getMapping(xDataType);
       final EDataType eDataType = _mapping.getEDataType();
       final XBlockExpression createBody = xDataType.getCreateBody();
       XDataTypeMapping _mapping_1 = this.mappings.getMapping(xDataType);
       final JvmOperation creator = _mapping_1.getCreator();
       boolean _and = false;
       boolean _notEquals = (!Objects.equal(createBody, null));
       if (!_notEquals) {
         _and = false;
       } else {
         boolean _notEquals_1 = (!Objects.equal(creator, null));
         _and = (_notEquals && _notEquals_1);
       }
       if (_and) {
         final XcoreAppendable appendable = this.createAppendable();
         EList<JvmFormalParameter> _parameters = creator.getParameters();
         JvmFormalParameter _get = _parameters.get(0);
         appendable.declareVariable(_get, "it");
         JvmTypeReference _returnType = creator.getReturnType();
         Set<JvmTypeReference> _emptySet = Collections.<JvmTypeReference>emptySet();
         this.compiler.compile(createBody, appendable, _returnType, _emptySet);
         String _string = appendable.toString();
         String _extractBody = this.extractBody(_string);
         EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "create", _extractBody);
       }
       final XBlockExpression convertBody = xDataType.getConvertBody();
       XDataTypeMapping _mapping_2 = this.mappings.getMapping(xDataType);
       final JvmOperation converter = _mapping_2.getConverter();
       boolean _and_1 = false;
       boolean _notEquals_2 = (!Objects.equal(convertBody, null));
       if (!_notEquals_2) {
         _and_1 = false;
       } else {
         boolean _notEquals_3 = (!Objects.equal(converter, null));
         _and_1 = (_notEquals_2 && _notEquals_3);
       }
       if (_and_1) {
         final XcoreAppendable appendable_1 = this.createAppendable();
         EList<JvmFormalParameter> _parameters_1 = converter.getParameters();
         JvmFormalParameter _get_1 = _parameters_1.get(0);
         appendable_1.declareVariable(_get_1, "it");
         JvmTypeReference _returnType_1 = converter.getReturnType();
         Set<JvmTypeReference> _emptySet_1 = Collections.<JvmTypeReference>emptySet();
         this.compiler.compile(convertBody, appendable_1, _returnType_1, _emptySet_1);
         String _string_1 = appendable_1.toString();
         String _extractBody_1 = this.extractBody(_string_1);
         EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "convert", _extractBody_1);
       }
     } else {
       final XClass xClass = ((XClass) xClassifier);
       XClassMapping _mapping_3 = this.mappings.getMapping(xClass);
       final EClass eClass = _mapping_3.getEClass();
       EList<EStructuralFeature> _eAllStructuralFeatures = eClass.getEAllStructuralFeatures();
       for (final EStructuralFeature eStructuralFeature : _eAllStructuralFeatures) {
         boolean _add = processed.add(eStructuralFeature);
         if (_add) {
           final XStructuralFeature xFeature = this.mappings.getXFeature(eStructuralFeature);
           boolean _notEquals_4 = (!Objects.equal(xFeature, null));
           if (_notEquals_4) {
             final XBlockExpression getBody = xFeature.getGetBody();
             boolean _notEquals_5 = (!Objects.equal(getBody, null));
             if (_notEquals_5) {
               XFeatureMapping _mapping_4 = this.mappings.getMapping(xFeature);
               final JvmOperation getter = _mapping_4.getGetter();
               final XcoreAppendable appendable_2 = this.createAppendable();
               JvmTypeReference _returnType_2 = getter.getReturnType();
               Set<JvmTypeReference> _emptySet_2 = Collections.<JvmTypeReference>emptySet();
               this.compiler.compile(getBody, appendable_2, _returnType_2, _emptySet_2);
               String _string_2 = appendable_2.toString();
               String _extractBody_2 = this.extractBody(_string_2);
               EcoreUtil.setAnnotation(
                   eStructuralFeature, GenModelPackage.eNS_URI, "get", _extractBody_2);
             }
           }
         }
       }
       EList<EOperation> _eAllOperations = eClass.getEAllOperations();
       for (final EOperation eOperation : _eAllOperations) {
         boolean _add_1 = processed.add(eOperation);
         if (_add_1) {
           final XOperation xOperation = this.mappings.getXOperation(eOperation);
           boolean _notEquals_6 = (!Objects.equal(xOperation, null));
           if (_notEquals_6) {
             final XBlockExpression body = xOperation.getBody();
             boolean _notEquals_7 = (!Objects.equal(body, null));
             if (_notEquals_7) {
               XOperationMapping _mapping_5 = this.mappings.getMapping(xOperation);
               final JvmOperation jvmOperation = _mapping_5.getJvmOperation();
               boolean _notEquals_8 = (!Objects.equal(jvmOperation, null));
               if (_notEquals_8) {
                 final XcoreAppendable appendable_3 = this.createAppendable();
                 JvmDeclaredType _declaringType = jvmOperation.getDeclaringType();
                 appendable_3.declareVariable(_declaringType, "this");
                 JvmDeclaredType _declaringType_1 = jvmOperation.getDeclaringType();
                 EList<JvmTypeReference> _superTypes = _declaringType_1.getSuperTypes();
                 final JvmTypeReference superType =
                     IterableExtensions.<JvmTypeReference>head(_superTypes);
                 boolean _notEquals_9 = (!Objects.equal(superType, null));
                 if (_notEquals_9) {
                   JvmType _type = superType.getType();
                   appendable_3.declareVariable(_type, "super");
                 }
                 EList<JvmFormalParameter> _parameters_2 = jvmOperation.getParameters();
                 for (final JvmFormalParameter parameter : _parameters_2) {
                   String _name = parameter.getName();
                   appendable_3.declareVariable(parameter, _name);
                 }
                 JvmTypeReference _returnType_3 = jvmOperation.getReturnType();
                 EList<JvmTypeReference> _exceptions = jvmOperation.getExceptions();
                 HashSet<JvmTypeReference> _hashSet = new HashSet<JvmTypeReference>(_exceptions);
                 this.compiler.compile(body, appendable_3, _returnType_3, _hashSet);
                 String _string_3 = appendable_3.toString();
                 String _extractBody_3 = this.extractBody(_string_3);
                 EcoreUtil.setAnnotation(
                     eOperation, GenModelPackage.eNS_URI, "body", _extractBody_3);
               }
             }
           }
         }
       }
     }
   }
 }
 public void buildMap(final GenModel genModel) {
   Iterable<EObject> _allContentsIterable = XcoreExtensions.allContentsIterable(genModel);
   for (final EObject genElement : _allContentsIterable) {
     boolean _matched = false;
     if (!_matched) {
       if (genElement instanceof GenPackage) {
         final GenPackage _genPackage = (GenPackage) genElement;
         _matched = true;
         EPackage _ecorePackage = _genPackage.getEcorePackage();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecorePackage);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XPackage xPackage = ((XPackage) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xPackage, null));
         if (_notEquals) {
           XPackageMapping _mapping = this.mapper.getMapping(xPackage);
           _mapping.setGenPackage(_genPackage);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genPackage);
           _toXcoreMapping_1.setXcoreElement(xPackage);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenClass) {
         final GenClass _genClass = (GenClass) genElement;
         _matched = true;
         EClass _ecoreClass = _genClass.getEcoreClass();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreClass);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XClass xClass = ((XClass) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xClass, null));
         if (_notEquals) {
           XClassMapping _mapping = this.mapper.getMapping(xClass);
           _mapping.setGenClass(_genClass);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genClass);
           _toXcoreMapping_1.setXcoreElement(xClass);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenDataType) {
         final GenDataType _genDataType = (GenDataType) genElement;
         _matched = true;
         EDataType _ecoreDataType = _genDataType.getEcoreDataType();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreDataType);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XDataType xDataType = ((XDataType) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xDataType, null));
         if (_notEquals) {
           XDataTypeMapping _mapping = this.mapper.getMapping(xDataType);
           _mapping.setGenDataType(_genDataType);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genDataType);
           _toXcoreMapping_1.setXcoreElement(xDataType);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenFeature) {
         final GenFeature _genFeature = (GenFeature) genElement;
         _matched = true;
         EStructuralFeature _ecoreFeature = _genFeature.getEcoreFeature();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreFeature);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XStructuralFeature xFeature = ((XStructuralFeature) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xFeature, null));
         if (_notEquals) {
           XFeatureMapping _mapping = this.mapper.getMapping(xFeature);
           _mapping.setGenFeature(_genFeature);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genFeature);
           _toXcoreMapping_1.setXcoreElement(xFeature);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenOperation) {
         final GenOperation _genOperation = (GenOperation) genElement;
         _matched = true;
         EOperation _ecoreOperation = _genOperation.getEcoreOperation();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreOperation);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XOperation xOperation = ((XOperation) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xOperation, null));
         if (_notEquals) {
           XOperationMapping _mapping = this.mapper.getMapping(xOperation);
           _mapping.setGenOperation(_genOperation);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genOperation);
           _toXcoreMapping_1.setXcoreElement(xOperation);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenParameter) {
         final GenParameter _genParameter = (GenParameter) genElement;
         _matched = true;
         EParameter _ecoreParameter = _genParameter.getEcoreParameter();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreParameter);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XParameter xParameter = ((XParameter) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xParameter, null));
         if (_notEquals) {
           XParameterMapping _mapping = this.mapper.getMapping(xParameter);
           _mapping.setGenParameter(_genParameter);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genParameter);
           _toXcoreMapping_1.setXcoreElement(xParameter);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenTypeParameter) {
         final GenTypeParameter _genTypeParameter = (GenTypeParameter) genElement;
         _matched = true;
         ETypeParameter _ecoreTypeParameter = _genTypeParameter.getEcoreTypeParameter();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreTypeParameter);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XTypeParameter xTypeParameter = ((XTypeParameter) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xTypeParameter, null));
         if (_notEquals) {
           XTypeParameterMapping _mapping = this.mapper.getMapping(xTypeParameter);
           _mapping.setGenTypeParameter(_genTypeParameter);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genTypeParameter);
           _toXcoreMapping_1.setXcoreElement(xTypeParameter);
         }
       }
     }
     if (!_matched) {
       if (genElement instanceof GenEnumLiteral) {
         final GenEnumLiteral _genEnumLiteral = (GenEnumLiteral) genElement;
         _matched = true;
         EEnumLiteral _ecoreEnumLiteral = _genEnumLiteral.getEcoreEnumLiteral();
         ToXcoreMapping _toXcoreMapping = this.mapper.getToXcoreMapping(_ecoreEnumLiteral);
         XNamedElement _xcoreElement = _toXcoreMapping.getXcoreElement();
         final XEnumLiteral xEnumLiteral = ((XEnumLiteral) _xcoreElement);
         boolean _notEquals = (!Objects.equal(xEnumLiteral, null));
         if (_notEquals) {
           XEnumLiteralMapping _mapping = this.mapper.getMapping(xEnumLiteral);
           _mapping.setGenEnumLiteral(_genEnumLiteral);
           ToXcoreMapping _toXcoreMapping_1 = this.mapper.getToXcoreMapping(_genEnumLiteral);
           _toXcoreMapping_1.setXcoreElement(xEnumLiteral);
         }
       }
     }
   }
 }