Search in sources :

Example 6 with NamedID

use of com.rockwellcollins.atc.agree.agree.NamedID in project AGREE by loonwerks.

the class FoldLeftExprImpl method basicSetBinding.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetBinding(NamedID newBinding, NotificationChain msgs) {
    NamedID oldBinding = binding;
    binding = newBinding;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.FOLD_LEFT_EXPR__BINDING, oldBinding, newBinding);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) NamedID(com.rockwellcollins.atc.agree.agree.NamedID)

Example 7 with NamedID

use of com.rockwellcollins.atc.agree.agree.NamedID in project AGREE by loonwerks.

the class FoldLeftExprImpl method basicSetAccumulator.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetAccumulator(NamedID newAccumulator, NotificationChain msgs) {
    NamedID oldAccumulator = accumulator;
    accumulator = newAccumulator;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.FOLD_LEFT_EXPR__ACCUMULATOR, oldAccumulator, newAccumulator);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) NamedID(com.rockwellcollins.atc.agree.agree.NamedID)

Example 8 with NamedID

use of com.rockwellcollins.atc.agree.agree.NamedID in project AGREE by loonwerks.

the class AgreeTypeSystem method typeDefFromNE.

public static TypeDef typeDefFromNE(NamedElement ne) {
    if (ne instanceof Classifier) {
        return typeDefFromClassifier((Classifier) ne);
    } else if (ne instanceof RecordDef) {
        EList<Arg> args = ((RecordDef) ne).getArgs();
        Map<String, TypeDef> fields = new HashMap<>();
        for (Arg arg : args) {
            String key = arg.getName();
            TypeDef typeDef = typeDefFromType(arg.getType());
            fields.put(key, typeDef);
        }
        return new RecordTypeDef(ne.getQualifiedName(), fields, ne);
    } else if (ne instanceof EnumStatement) {
        String name = ne.getQualifiedName();
        List<String> enumValues = new ArrayList<String>();
        for (NamedID nid : ((EnumStatement) ne).getEnums()) {
            String enumValue = name + "_" + nid.getName();
            enumValues.add(enumValue);
        }
        return new EnumTypeDef(name, enumValues, ne);
    } else if (ne instanceof Arg) {
        return typeDefFromType(((Arg) ne).getType());
    } else {
        return Prim.ErrorTypeDef;
    }
}
Also used : ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) AadlString(org.osate.aadl2.AadlString) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) EList(org.eclipse.emf.common.util.EList) Arg(com.rockwellcollins.atc.agree.agree.Arg) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) Map(java.util.Map) HashMap(java.util.HashMap) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef)

Example 9 with NamedID

use of com.rockwellcollins.atc.agree.agree.NamedID in project AGREE by loonwerks.

the class AgreeLinkingService 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 (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 UninterpretedFnDef) {
                        if (((UninterpretedFnDef) 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) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) 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) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) EList(org.eclipse.emf.common.util.EList) 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)

Example 10 with NamedID

use of com.rockwellcollins.atc.agree.agree.NamedID 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

NamedID (com.rockwellcollins.atc.agree.agree.NamedID)17 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)6 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)6 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)6 AgreeTypeSystem (com.rockwellcollins.atc.agree.AgreeTypeSystem)5 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)5 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)5 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)5 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)5 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)5 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)5 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)5 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)5 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)5 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)5 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)5 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)5 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)5 IndicesExpr (com.rockwellcollins.atc.agree.agree.IndicesExpr)5 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)5