Search in sources :

Example 1 with GenClassifier

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

the class GenModelUtil2 method getGenClassifier.

public static GenClassifier getGenClassifier(final EClassifier cls, final ResourceSet resourceSet) {
    final GenPackage genPackage = GenModelUtil2.getGenPackage(cls.getEPackage(), resourceSet);
    EList<GenClassifier> _genClassifiers = genPackage.getGenClassifiers();
    for (final GenClassifier genCls : _genClassifiers) {
        String _name = cls.getName();
        String _name_1 = genCls.getEcoreClassifier().getName();
        boolean _equals = Objects.equal(_name, _name_1);
        if (_equals) {
            return genCls;
        }
    }
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("No GenClassifier named \'");
    String _name_2 = cls.getName();
    _builder.append(_name_2);
    _builder.append("\' found in GenModel ");
    URI _uRI = genPackage.eResource().getURI();
    _builder.append(_uRI);
    throw new RuntimeException(_builder.toString());
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) GenPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage) GenClassifier(org.eclipse.emf.codegen.ecore.genmodel.GenClassifier) URI(org.eclipse.emf.common.util.URI)

Example 2 with GenClassifier

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

the class GenModelUtil2 method getTypeLiteral.

public static String getTypeLiteral(final EClassifier classifier, final ResourceSet resourceSet) {
    final GenClassifier genClassifier = GenModelUtil2.getGenClassifier(classifier, resourceSet);
    boolean _isLiteralsInterface = genClassifier.getGenPackage().isLiteralsInterface();
    if (_isLiteralsInterface) {
        String _classifierID = genClassifier.getClassifierID();
        return ("Literals." + _classifierID);
    } else {
        String _classifierAccessorName = genClassifier.getClassifierAccessorName();
        String _plus = ("eINSTANCE.get" + _classifierAccessorName);
        return (_plus + "()");
    }
}
Also used : GenClassifier(org.eclipse.emf.codegen.ecore.genmodel.GenClassifier)

Example 3 with GenClassifier

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

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