Search in sources :

Example 16 with EClassifier

use of org.eclipse.emf.ecore.EClassifier in project BIMserver by opensourceBIM.

the class AttributeCondition method getEClassRequirements.

@Override
public void getEClassRequirements(Set<EClass> classRequirements) {
    EClass eClass = attribute.getEContainingClass();
    classRequirements.add(eClass);
    for (EClassifier subClass : eClass.getEPackage().getEClassifiers()) {
        if (subClass instanceof EClass && eClass.isSuperTypeOf((EClass) subClass)) {
            classRequirements.add((EClass) subClass);
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassifier(org.eclipse.emf.ecore.EClassifier)

Example 17 with EClassifier

use of org.eclipse.emf.ecore.EClassifier in project BIMserver by opensourceBIM.

the class Schema method addEPackage.

public void addEPackage(EPackage ePackage) {
    packages.put(ePackage.getName(), ePackage);
    changes.add(new NewPackageChange(ePackage));
    Set<EClass> newClasses = new HashSet<>();
    for (EClassifier eClassifier : ePackage.getEClassifiers()) {
        if (eClassifier instanceof EClass) {
            newClasses.add((EClass) eClassifier);
        }
    }
    addEClasses(ePackage, newClasses);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassifier(org.eclipse.emf.ecore.EClassifier) NewPackageChange(org.bimserver.database.migrations.change.NewPackageChange) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 18 with EClassifier

use of org.eclipse.emf.ecore.EClassifier in project BIMserver by opensourceBIM.

the class Schema method initIndirectSubClasses.

private void initIndirectSubClasses(EClass eClass) {
    HashSet<EClass> set = new HashSet<EClass>();
    indirectSubClasses.put(eClass, set);
    set.add(eClass);
    for (EClassifier eClassifier : eClass.getEPackage().getEClassifiers()) {
        if (eClassifier instanceof EClass) {
            EClass e = (EClass) eClassifier;
            if (eClass.isSuperTypeOf(e)) {
                set.add(e);
            }
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassifier(org.eclipse.emf.ecore.EClassifier) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 19 with EClassifier

use of org.eclipse.emf.ecore.EClassifier in project Malai by arnobl.

the class InstrumentModelWizard method getInitialObjectNames.

/**
 * Returns the names of the types that can be created as the root object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<String> getInitialObjectNames() {
    if (initialObjectNames == null) {
        initialObjectNames = new ArrayList<String>();
        for (EClassifier eClassifier : instrumentPackage.getEClassifiers()) {
            if (eClassifier instanceof EClass) {
                EClass eClass = (EClass) eClassifier;
                if (!eClass.isAbstract()) {
                    initialObjectNames.add(eClass.getName());
                }
            }
        }
        Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
    }
    return initialObjectNames;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassifier(org.eclipse.emf.ecore.EClassifier)

Example 20 with EClassifier

use of org.eclipse.emf.ecore.EClassifier in project xtext-eclipse by eclipse.

the class XtextProposalProvider method appendReturnType.

protected boolean appendReturnType(final AbstractRule overrideMe, final Grammar grammar, StringBuilder newRuleFragment) {
    if (overrideMe instanceof ParserRule && ((ParserRule) overrideMe).isWildcard()) {
        newRuleFragment.append(" *");
        // no need to add an import to the grammar
        return true;
    } else {
        EClassifier classifier = overrideMe.getType().getClassifier();
        final EPackage classifierPackage = classifier.getEPackage();
        boolean foundPack = false;
        for (AbstractMetamodelDeclaration metamodel : grammar.getMetamodelDeclarations()) {
            EPackage available = metamodel.getEPackage();
            if (classifierPackage == available) {
                EDataType eString = GrammarUtil.findEString(grammar);
                if (eString == null)
                    eString = EcorePackage.Literals.ESTRING;
                if (classifier != eString && (!Strings.isEmpty(metamodel.getAlias()) || !classifier.getName().equals(overrideMe.getName()))) {
                    newRuleFragment.append(" returns ");
                    if (!Strings.isEmpty(metamodel.getAlias())) {
                        newRuleFragment.append(metamodel.getAlias()).append("::");
                    }
                    newRuleFragment.append(classifier.getName());
                }
                foundPack = true;
                break;
            }
        }
        if (!foundPack) {
            EDataType eString = GrammarUtil.findEString(grammar);
            if (eString == null)
                eString = EcorePackage.Literals.ESTRING;
            if (classifier == eString) {
                for (AbstractMetamodelDeclaration mm : GrammarUtil.allMetamodelDeclarations(grammar)) {
                    if (mm.getEPackage() == classifierPackage) {
                        foundPack = true;
                        break;
                    }
                }
            }
            if (!foundPack) {
                newRuleFragment.append(" returns ");
                newRuleFragment.append(classifierPackage.getName());
                newRuleFragment.append("::");
                newRuleFragment.append(classifier.getName());
            }
        }
        return foundPack;
    }
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) EDataType(org.eclipse.emf.ecore.EDataType) EClassifier(org.eclipse.emf.ecore.EClassifier) AbstractMetamodelDeclaration(org.eclipse.xtext.AbstractMetamodelDeclaration) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

EClassifier (org.eclipse.emf.ecore.EClassifier)192 EClass (org.eclipse.emf.ecore.EClass)132 Test (org.junit.Test)81 EPackage (org.eclipse.emf.ecore.EPackage)75 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)61 EObject (org.eclipse.emf.ecore.EObject)23 EReference (org.eclipse.emf.ecore.EReference)21 AbstractRule (org.eclipse.xtext.AbstractRule)19 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)18 Grammar (org.eclipse.xtext.Grammar)16 EDataType (org.eclipse.emf.ecore.EDataType)13 XtextResource (org.eclipse.xtext.resource.XtextResource)12 AbstractElement (org.eclipse.xtext.AbstractElement)11 EEnum (org.eclipse.emf.ecore.EEnum)8 ParserRule (org.eclipse.xtext.ParserRule)8 EAttribute (org.eclipse.emf.ecore.EAttribute)7 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)7 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)7 Assignment (org.eclipse.xtext.Assignment)7 ArrayList (java.util.ArrayList)6