Search in sources :

Example 16 with ErrorModelLibrary

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.

the class EMV2TypeSetUtil method getSubTypes.

/**
 * Get all error types that are direct subtypes of et or any of its aliases.
 * If et is an alias we only find subtypes of the alias or its aliases
 * We look for any error type accessible in the TypeUseContext, i.e., subclause, type library, type mapping/xform set
 * @param et
 * @param tuc
 * @return
 */
public static EList<ErrorType> getSubTypes(ErrorType et, List<ErrorModelLibrary> usetypes) {
    UniqueEList<ErrorType> result = new UniqueEList<ErrorType>();
    ErrorType resolvedet = EMV2Util.resolveAlias(et);
    for (ErrorModelLibrary etl : usetypes) {
        EList<ErrorType> typeslist = etl.getTypes();
        for (ErrorType suberrortype : typeslist) {
            // check if type is a subtype or an alias for which we need to check for subtypes
            ErrorType resolvedSubErrorType = EMV2Util.resolveAlias(suberrortype);
            if (resolvedSubErrorType == resolvedet) {
                // subtype is an alias of ET. need to look for its subtypes
                EList<ErrorType> aliasresult = getSubTypes(suberrortype, usetypes);
                result.addAll(aliasresult);
            }
            if (suberrortype.getSuperType() == et) {
                result.add(suberrortype);
            }
            ErrorType aliasedsubtype = suberrortype;
            while (isAlias(aliasedsubtype)) {
                // see if the alias origin is a subtype
                ErrorType sub = aliasedsubtype.getAliasedType();
                if (sub.getSuperType() == et) {
                    result.add(sub);
                } else {
                    aliasedsubtype = sub;
                }
            }
        }
    }
    return result;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) UniqueEList(org.eclipse.emf.common.util.UniqueEList)

Aggregations

ErrorModelLibrary (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary)14 ErrorType (org.osate.xtext.aadl2.errormodel.errorModel.ErrorType)8 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)4 UniqueEList (org.eclipse.emf.common.util.UniqueEList)3 EObject (org.eclipse.emf.ecore.EObject)3 Hashtable (java.util.Hashtable)2 AadlPackage (org.osate.aadl2.AadlPackage)2 ErrorModelSubclause (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause)2 ErrorTypes (org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)2 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)2 BasicEList (org.eclipse.emf.common.util.BasicEList)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Composite (org.eclipse.swt.widgets.Composite)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1