Search in sources :

Example 6 with EnumStatement

use of com.rockwellcollins.atc.agree.agree.EnumStatement in project AMASE by loonwerks.

the class SafetyScopeProvider method getNamedElementsFromSpecs.

private Set<NamedElement> getNamedElementsFromSpecs(EList<SpecStatement> agreeSpecs) {
    Set<NamedElement> nelms = new HashSet<>();
    for (SpecStatement spec : agreeSpecs) {
        if (spec instanceof NamedElement) {
            nelms.add((NamedElement) spec);
        }
        if (spec instanceof EqStatement) {
            EqStatement eq = (EqStatement) spec;
            nelms.addAll(eq.getLhs());
        } else if (spec instanceof InputStatement) {
            nelms.addAll(((InputStatement) spec).getLhs());
        } else if (spec instanceof EnumStatement) {
            nelms.addAll(((EnumStatement) spec).getEnums());
        }
    }
    return nelms;
}
Also used : EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) SafetyEqStatement(edu.umn.cs.crisys.safety.safety.SafetyEqStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) NamedElement(org.osate.aadl2.NamedElement) HashSet(java.util.HashSet)

Example 7 with EnumStatement

use of com.rockwellcollins.atc.agree.agree.EnumStatement in project AMASE by loonwerks.

the class SafetyLinkingService method getElm.

private Element getElm(EObject context, EReference reference, String name) {
    String[] segments = name.split("::");
    if (segments.length >= 2) {
        String pkgName = String.join("::", Arrays.copyOf(segments, segments.length - 1));
        String statementName = segments[segments.length - 1];
        Namespace namespace = AadlUtil.getContainingTopLevelNamespace(context);
        PropertySet propSet = AadlUtil.findImportedPropertySet(pkgName, namespace);
        if (propSet != null) {
            Element elm = propSet.findNamedElement(statementName);
            return elm;
        }
        AadlPackage aadlPackage = AadlUtil.findImportedPackage(pkgName, namespace);
        if (aadlPackage == null) {
            for (PackageRename rename : EcoreUtil2.getAllContentsOfType(namespace.getElementRoot(), PackageRename.class)) {
                if (rename.getName() != null && pkgName.equals(rename.getName())) {
                    aadlPackage = rename.getRenamedPackage();
                }
            }
        }
        if (aadlPackage != null) {
            for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(aadlPackage, AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
                AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
                for (com.rockwellcollins.atc.agree.agree.SpecStatement spec : contract.getSpecs()) {
                    if (spec instanceof RecordDef) {
                        if (((RecordDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof FnDef) {
                        if (((FnDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof LibraryFnDef) {
                        if (((LibraryFnDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof NodeDef) {
                        if (((NodeDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof LinearizationDef) {
                        if (((LinearizationDef) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof ConstStatement) {
                        if (((ConstStatement) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                    } else if (spec instanceof EnumStatement) {
                        if (((EnumStatement) spec).getName().equals(statementName)) {
                            return (spec);
                        }
                        EList<NamedID> enums = ((EnumStatement) spec).getEnums();
                        for (NamedID nid : enums) {
                            if (nid.getName().contentEquals(statementName)) {
                                return nid;
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) AadlPackage(org.osate.aadl2.AadlPackage) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) Element(org.osate.aadl2.Element) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Namespace(org.osate.aadl2.Namespace) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) PackageRename(org.osate.aadl2.PackageRename) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) PropertySet(org.osate.aadl2.PropertySet) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef)

Aggregations

EnumStatement (com.rockwellcollins.atc.agree.agree.EnumStatement)7 RecordDef (com.rockwellcollins.atc.agree.agree.RecordDef)4 NamedElement (org.osate.aadl2.NamedElement)4 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)3 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)3 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)3 NamedID (com.rockwellcollins.atc.agree.agree.NamedID)3 SpecStatement (com.rockwellcollins.atc.agree.agree.SpecStatement)3 AadlPackage (org.osate.aadl2.AadlPackage)3 AgreeContract (com.rockwellcollins.atc.agree.agree.AgreeContract)2 FnDef (com.rockwellcollins.atc.agree.agree.FnDef)2 LibraryFnDef (com.rockwellcollins.atc.agree.agree.LibraryFnDef)2 LinearizationDef (com.rockwellcollins.atc.agree.agree.LinearizationDef)2 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 EList (org.eclipse.emf.common.util.EList)2 EObject (org.eclipse.emf.ecore.EObject)2 AnnexLibrary (org.osate.aadl2.AnnexLibrary)2 ComponentClassifier (org.osate.aadl2.ComponentClassifier)2