use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.
the class EMV2Util method recursiveCheckCyclicExtends.
private static boolean recursiveCheckCyclicExtends(ErrorModelLibrary etl, HashSet<ErrorModelLibrary> shetl) {
boolean result = false;
if (etl.getExtends() != null) {
shetl.add(etl);
EList<ErrorModelLibrary> etllist = etl.getExtends();
for (ErrorModelLibrary xetl : etllist) {
if (shetl.contains(xetl)) {
result = true;
} else {
result = result || recursiveCheckCyclicExtends(xetl, shetl);
}
}
shetl.remove(etl);
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.
the class ErrorModelValidator method recursiveCheckCyclicExtends.
private boolean recursiveCheckCyclicExtends(ErrorModelLibrary etl, HashSet<ErrorModelLibrary> shetl) {
boolean result = false;
if (etl.getExtends() != null) {
shetl.add(etl);
EList<ErrorModelLibrary> etllist = etl.getExtends();
for (ErrorModelLibrary xetl : etllist) {
if (shetl.contains(xetl)) {
error(xetl, "Cycle in extends of error type library " + etl.getName());
result = true;
} else {
result = result || recursiveCheckCyclicExtends(xetl, shetl);
}
}
shetl.remove(etl);
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.
the class ErrorModelValidator method checkMultipleErrorTypesInUsesTypes.
private void checkMultipleErrorTypesInUsesTypes(Element useTypesContext) {
Hashtable<String, EObject> etlset = new Hashtable<String, EObject>(10, 10);
for (ErrorModelLibrary etl : EMV2Util.getUseTypes(useTypesContext)) {
EList<ErrorType> typeslist = etl.getTypes();
for (ErrorType errorTypes : typeslist) {
if (etlset.containsKey(errorTypes.getName())) {
ErrorModelLibrary eml = EMV2Util.getContainingErrorModelLibrary((Element) etlset.get(errorTypes.getName()));
error(useTypesContext, "Error type or type set " + errorTypes.getName() + " in library " + EMV2Util.getPrintName(etl) + " already exists in error type library " + EMV2Util.getPrintName(eml));
} else {
etlset.put(errorTypes.getName(), errorTypes);
}
}
EList<TypeSet> typesetlist = etl.getTypesets();
for (TypeSet typeset : typesetlist) {
if (etlset.containsKey(typeset.getName())) {
ErrorModelLibrary eml = EMV2Util.getContainingErrorModelLibrary((Element) etlset.get(typeset.getName()));
error(useTypesContext, "Error type or type set " + typeset.getName() + " in library " + EMV2Util.getPrintName(etl) + " already exists in error type library " + EMV2Util.getPrintName(eml));
} else {
etlset.put(typeset.getName(), typeset);
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.
the class EMV2TypeSetUtil method contains.
/**
* Dispatch on ErrorTypes
*/
public static boolean contains(ErrorTypes constraint, ErrorType type) {
if (constraint instanceof ErrorType) {
return contains((ErrorType) constraint, type);
}
if (constraint instanceof TypeSet) {
ErrorModelLibrary el = EMV2Util.getContainingErrorModelLibrary(type);
EList<ErrorType> subtypes = null;
if (el != null) {
subtypes = getAllLeafSubTypes(type, el);
} else {
subtypes = getAllLeafSubTypes(type, EMV2Util.getUseTypes(type));
}
if (subtypes.isEmpty()) {
return contains((TypeSet) constraint, type);
} else {
for (ErrorType st : subtypes) {
if (!contains((TypeSet) constraint, st)) {
return false;
}
}
return true;
}
}
return true;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary in project osate2 by osate.
the class EMV2TypeSetUtil method generateAllLeafTypeTokens.
/**
* generate all type tokens for a given typeset.
* Do so for each leaf subtype.
* @param typeSet
* @return list of type tokens
*/
public static EList<TypeToken> generateAllLeafTypeTokens(TypeSet typeSet, List<ErrorModelLibrary> usetypes) {
EList<TypeToken> result = new BasicEList<TypeToken>();
if (typeSet == null) {
return result;
}
EList<TypeToken> typelist = typeSet.getTypeTokens();
for (TypeToken typeSetElement : typelist) {
// add all leaf nodes
EList<TypeToken> newitems = new BasicEList<TypeToken>();
EList<ErrorTypes> elementtypes = typeSetElement.getType();
for (ErrorTypes errorType : elementtypes) {
if (errorType instanceof ErrorType) {
// elements of a product type
EList<ErrorType> etlist = getAllLeafSubTypes((ErrorType) errorType, usetypes);
if (newitems.isEmpty()) {
// first/single type: add all leaves
for (ErrorType subType : etlist) {
TypeToken token = ErrorModelFactory.eINSTANCE.createTypeToken();
token.getType().add(subType);
newitems.add(token);
}
} else {
// product type: add other type elements from the product type
newitems = addItemSet(newitems, etlist);
}
} else {
EList<TypeToken> etlist = generateAllLeafTypeTokens((TypeSet) errorType, usetypes);
newitems.addAll(etlist);
}
}
result.addAll(newitems);
newitems.clear();
}
return result;
}
Aggregations