Search in sources :

Example 1 with GenFeature

use of org.eclipse.emf.codegen.ecore.genmodel.GenFeature 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 GenFeature

use of org.eclipse.emf.codegen.ecore.genmodel.GenFeature 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)

Example 3 with GenFeature

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

the class SerializerFragment2 method getUnresolvingGetAccessor.

private StringConcatenationClient getUnresolvingGetAccessor(final EStructuralFeature feature, final ResourceSet resourceSet) {
    final GenFeature genFeature = GenModelUtil2.getGenFeature(feature, resourceSet);
    boolean _isResolveProxies = genFeature.isResolveProxies();
    if (_isResolveProxies) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("eGet(");
                EPackage _ecorePackage = genFeature.getGenPackage().getEcorePackage();
                _builder.append(_ecorePackage);
                _builder.append(".");
                String _featureLiteral = GenModelUtil2.getFeatureLiteral(genFeature, resourceSet);
                _builder.append(_featureLiteral);
                _builder.append(", false)");
            }
        };
        return _client;
    } else {
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                String _getAccessor = GenModelUtil2.getGetAccessor(genFeature, resourceSet);
                _builder.append(_getAccessor);
                _builder.append("()");
            }
        };
        return _client_1;
    }
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) GenFeature(org.eclipse.emf.codegen.ecore.genmodel.GenFeature) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

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