use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class EMV2TypeSetUtil method reverseMapTypeToken.
/**
* map a TypeToken from the target type token to the first type token in the source type set according to the TypeMappingSet.
* The original token is not modified.
* The result token is currently that from the mapping rule and is not expected to be modified
* @param token TypeToken
* @param tms TypeMappingSet
* @return result TypeToken or null if no mapping found
*/
public static TypeToken reverseMapTypeToken(TypeToken token, TypeMappingSet tms) {
EList<TypeMapping> tmlist = tms.getMapping();
for (TypeMapping typeMapping : tmlist) {
TypeSet src = typeMapping.getSource();
TypeSet trg = typeMapping.getTarget();
if (contains(trg, token)) {
return src.getTypeTokens().get(0);
}
}
return null;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class EMV2TypeSetUtil method getConstrainedTypeTokens.
/**
* returns all subtypes of the token that are in TypeSet ts
* The type set can represent a constraint
* aliases are resolved before the error types are compared
* @param ts TypeSet
* @param token TypeToken
* @return list TypeToken
*/
public static Collection<TypeToken> getConstrainedTypeTokens(TypeSet ts, TypeToken token) {
BasicEList<TypeToken> result = new BasicEList<TypeToken>();
if (token == null) {
return result;
}
if (ts == null) {
result.add(token);
return result;
}
ts = EMV2Util.resolveAlias(ts);
int toksize = token.getType().size();
for (TypeToken tselement : ts.getTypeTokens()) {
if (tselement.getType().size() == toksize) {
getConstrainedTypeTokens(tselement, token, result);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class EMV2TypeSetUtil method addItemSet.
/**
* add type token for specified error type to newItems. Then add a token
* for each token in existing list with error type added.
* @param newItems list holding the newly added tokens
* @param etlist error subtypes of the next product element to be added
* @return result list
*/
protected static EList<TypeToken> addItemSet(EList<TypeToken> newItems, EList<ErrorType> etlist) {
EList<TypeToken> result = new BasicEList<TypeToken>();
for (TypeToken typeToken : newItems) {
for (ErrorType et : etlist) {
TypeToken tu = EcoreUtil.copy(typeToken);
tu.getType().add(et);
result.add(tu);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class EMV2TypeSetUtil method mapTokenThroughConstraint.
/**
* Reverse mapping of type token.
* If contained in constraint return it, or subtype(s) of it when present in contraint (propagation)
* If no match, then we have a transformation. return the types from the constraint.
* @param constraint
* @param proptype
* @return collection of error type
*/
public static EList<TypeToken> mapTokenThroughConstraint(TypeSet constraint, TypeToken proptype) {
EList<TypeToken> result = new BasicEList<TypeToken>();
if (constraint == null && proptype == null) {
return result;
}
if (proptype == null) {
// any constraint element is mapped to outgoing
return EMV2TypeSetUtil.flattenTypesetElements(constraint);
}
// constraint contains subtype(s) of proptype. Use those
EList<TypeToken> tokens = EMV2TypeSetUtil.flattenTypesetElements(constraint);
for (TypeToken token : tokens) {
if (EMV2TypeSetUtil.contains(token, proptype)) {
// include types that are the same or subtypes of propagated type
if (!isNoError(proptype)) {
result.add(proptype);
}
} else {
result.add(token);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.
the class EMV2TypeSetUtil method flattenTypesetElements.
/**
* generate all error types for a given typeset.
* Do so recursively for contained type sets.
* @param typeSet
* @return list of type tokens that are error types
*/
public static EList<TypeToken> flattenTypesetElements(TypeSet typeSet) {
EList<TypeToken> result = new BasicEList<TypeToken>();
if (typeSet == null) {
return result;
}
EList<TypeToken> typelist = typeSet.getTypeTokens();
for (TypeToken typeSetElement : typelist) {
// add all error type elements (but not their subtypes)
EList<ErrorTypes> elementtypes = typeSetElement.getType();
if (!elementtypes.isEmpty()) {
ErrorTypes first = elementtypes.get(0);
if (first instanceof ErrorType) {
// error type or type product
if (!EMV2TypeSetUtil.contains(result, typeSetElement)) {
result.add(typeSetElement);
}
} else {
// we have a type set that needs to be flattened
EList<TypeToken> etlist = flattenTypesetElements((TypeSet) first);
for (TypeToken typeToken : etlist) {
if (!EMV2TypeSetUtil.contains(result, typeToken)) {
result.add(typeToken);
}
}
}
}
}
return result;
}
Aggregations