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;
}
Aggregations