Search in sources :

Example 11 with ErrorModelLibrary

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;
}
Also used : ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary)

Example 12 with ErrorModelLibrary

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;
}
Also used : ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary)

Example 13 with ErrorModelLibrary

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);
            }
        }
    }
}
Also used : ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) Hashtable(java.util.Hashtable) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

Example 14 with ErrorModelLibrary

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;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)

Example 15 with ErrorModelLibrary

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;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) BasicEList(org.eclipse.emf.common.util.BasicEList) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

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