Search in sources :

Example 1 with GenClass

use of org.eclipse.emf.codegen.ecore.genmodel.GenClass in project xtext-core by eclipse.

the class GenModelUtil2 method getGetAccessor.

public static String getGetAccessor(final GenFeature genFeature, final ResourceSet resourceSet) {
    final GenClass genClass = genFeature.getGenClass();
    boolean _isMapEntry = genClass.isMapEntry();
    if (_isMapEntry) {
        GenFeature _mapEntryKeyFeature = genClass.getMapEntryKeyFeature();
        boolean _equals = Objects.equal(genFeature, _mapEntryKeyFeature);
        if (_equals) {
            return "getKey";
        }
        GenFeature _mapEntryValueFeature = genClass.getMapEntryValueFeature();
        boolean _equals_1 = Objects.equal(genFeature, _mapEntryValueFeature);
        if (_equals_1) {
            return "getValue";
        }
    }
    return genFeature.getGetAccessor();
}
Also used : GenClass(org.eclipse.emf.codegen.ecore.genmodel.GenClass) GenFeature(org.eclipse.emf.codegen.ecore.genmodel.GenFeature)

Example 2 with GenClass

use of org.eclipse.emf.codegen.ecore.genmodel.GenClass in project xtext-core by eclipse.

the class GenModelUtil2 method getGenFeature.

public static GenFeature getGenFeature(final EStructuralFeature feature, final ResourceSet resourceSet) {
    GenClassifier _genClassifier = GenModelUtil2.getGenClassifier(feature.getEContainingClass(), resourceSet);
    final GenClass genCls = ((GenClass) _genClassifier);
    EList<GenFeature> _genFeatures = genCls.getGenFeatures();
    for (final GenFeature genFeat : _genFeatures) {
        String _name = feature.getName();
        String _name_1 = genFeat.getEcoreFeature().getName();
        boolean _equals = Objects.equal(_name, _name_1);
        if (_equals) {
            return genFeat;
        }
    }
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("No GenFeature named \'");
    String _name_2 = feature.getName();
    _builder.append(_name_2);
    _builder.append("\' found in GenClass \'");
    _builder.append(genCls);
    _builder.append("\' from GenModel");
    URI _uRI = genCls.eResource().getURI();
    _builder.append(_uRI);
    throw new RuntimeException(_builder.toString());
}
Also used : GenClass(org.eclipse.emf.codegen.ecore.genmodel.GenClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) GenFeature(org.eclipse.emf.codegen.ecore.genmodel.GenFeature) GenClassifier(org.eclipse.emf.codegen.ecore.genmodel.GenClassifier) URI(org.eclipse.emf.common.util.URI)

Aggregations

GenClass (org.eclipse.emf.codegen.ecore.genmodel.GenClass)2 GenFeature (org.eclipse.emf.codegen.ecore.genmodel.GenFeature)2 GenClassifier (org.eclipse.emf.codegen.ecore.genmodel.GenClassifier)1 URI (org.eclipse.emf.common.util.URI)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1