Search in sources :

Example 1 with EMV2PathElement

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement in project osate2 by osate.

the class EMV2PathImpl method basicSetEmv2Target.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetEmv2Target(EMV2PathElement newEmv2Target, NotificationChain msgs) {
    EMV2PathElement oldEmv2Target = emv2Target;
    emv2Target = newEmv2Target;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ErrorModelPackage.EMV2_PATH__EMV2_TARGET, oldEmv2Target, newEmv2Target);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 2 with EMV2PathElement

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement in project osate2 by osate.

the class EMV2PathElementImpl method basicSetPath.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetPath(EMV2PathElement newPath, NotificationChain msgs) {
    EMV2PathElement oldPath = path;
    path = newPath;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ErrorModelPackage.EMV2_PATH_ELEMENT__PATH, oldPath, newPath);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 3 with EMV2PathElement

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement in project osate2 by osate.

the class ErrorModelValidator method checkAssociationAppliesTo.

private void checkAssociationAppliesTo(final EMV2PropertyAssociation pa) {
    final Property pn = pa.getProperty();
    final EList<EMV2Path> appliesTo = pa.getEmv2Path();
    if (appliesTo == null || appliesTo.size() == 0) {
        Element element = pa.getOwner();
        if (element instanceof NamedElement) {
            final boolean applies = ((NamedElement) element).acceptsProperty(pn);
            if (!applies) {
                error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
            // error(pa,
            // "Property " + pa.getQualifiedName() +
            // " does not apply to " + element.eClass().getName());
            }
        }
    } else {
        for (EMV2Path cna : appliesTo) {
            EMV2PathElement path = cna.getEmv2Target();
            if (path != null) {
                // only the last value is interesting to us
                final EMV2PathElement ph = EMV2Util.getLast(path);
                NamedElement ne = ph.getNamedElement();
                if (ne instanceof ErrorTypes) {
                    ErrorTypes et = (ErrorTypes) ne;
                    EObject prev = ph.eContainer();
                    if (prev instanceof EMV2PathElement) {
                        ne = ((EMV2PathElement) prev).getNamedElement();
                        boolean noMatch = false;
                        if (ne instanceof ErrorBehaviorState) {
                            TypeSet ts = ((ErrorBehaviorState) ne).getTypeSet();
                            noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
                        } else if (ne instanceof ErrorPropagation) {
                            String epname = EMV2Util.getPrintName((ErrorPropagation) ne);
                            EList<ErrorPropagation> eplist = EMV2Util.getContainingErrorModelSubclause(ne).getPropagations();
                            Boolean foundType = false;
                            for (ErrorPropagation ep : eplist) {
                                if (epname.equalsIgnoreCase(EMV2Util.getPrintName(ep))) {
                                    TypeSet ts = ep.getTypeSet();
                                    if (EMV2TypeSetUtil.contains(ts, et)) {
                                        foundType = true;
                                        break;
                                    }
                                }
                            }
                            noMatch = !foundType;
                        } else if (ne instanceof ErrorEvent) {
                            TypeSet ts = ((ErrorEvent) ne).getTypeSet();
                            noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
                        }
                        if (noMatch) {
                            error(pa, "Property " + pa.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
                        }
                    }
                }
                if (!Aadl2Util.isNull(ne)) {
                    final boolean applies = ph.getNamedElement().acceptsProperty(pn);
                    if (!applies) {
                        error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + EMV2Util.getPrintName(cna));
                    }
                }
            }
        }
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 4 with EMV2PathElement

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement in project osate2 by osate.

the class EMV2Util method getLastComponentInstance.

/**
 * get the last component instance in the epath relative to the component instance root
 * Returns root if the path does not include subcomponents.
 * Returns null if the component instance is not found, i.e., the path subcomponent references cannot be found in the
 * component instance hierarchy.
 * @param epath EMV2Path that includes EMV2PathElements pointing to subcomponents.
 * @param root ComponentInstance that is the root of the subcomponent section of the path
 * @return ComponentInstance
 */
public static ComponentInstance getLastComponentInstance(EMV2Path epath, ComponentInstance root) {
    ComponentInstance result = root;
    if (epath.getContainmentPath() != null) {
        // handle paths that come from the EMV2PropertyAssociation with the new syntax for the core path
        ContainmentPathElement ce = epath.getContainmentPath();
        while (ce != null && result != null) {
            if (ce.getNamedElement() instanceof Subcomponent) {
                Subcomponent sub = (Subcomponent) ce.getNamedElement();
                result = result.findSubcomponentInstance(sub);
            }
            ce = ce.getPath();
        }
        return result;
    }
    EMV2PathElement epe = epath.getEmv2Target();
    while (epe != null && result != null) {
        if (epe.getNamedElement() instanceof Subcomponent) {
            Subcomponent sub = (Subcomponent) epe.getNamedElement();
            result = result.findSubcomponentInstance(sub);
        }
        epe = epe.getPath();
    }
    return result;
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Example 5 with EMV2PathElement

use of org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement in project osate2 by osate.

the class EMV2Util method getPrintName.

public static String getPrintName(EMV2Path ep) {
    if (ep == null) {
        return "";
    }
    EMV2PathElement epe = ep.getEmv2Target();
    if (epe == null) {
        return "";
    }
    ContainmentPathElement cpe = ep.getContainmentPath();
    String prefix;
    if (cpe == null) {
        prefix = "";
    } else {
        prefix = "^" + cpe.getNamedElement().getName();
        cpe = cpe.getPath();
    }
    while (cpe != null) {
        prefix = prefix + "." + cpe.getNamedElement().getName();
        cpe = cpe.getPath();
    }
    if (!prefix.isEmpty()) {
        prefix = prefix + '@';
    }
    if (epe.getEmv2PropagationKind() != null) {
        return prefix + epe.getEmv2PropagationKind() + (epe.getErrorType() != null ? "." + epe.getErrorType().getName() : "");
    } else {
        return getPathName(epe);
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Aggregations

EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)10 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)7 EObject (org.eclipse.emf.ecore.EObject)3 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 Subcomponent (org.osate.aadl2.Subcomponent)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 NamedElement (org.osate.aadl2.NamedElement)2 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)2 EMV2Path (org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path)2 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)2 Optional (java.util.Optional)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 EList (org.eclipse.emf.common.util.EList)1 URI (org.eclipse.emf.common.util.URI)1 EPackage (org.eclipse.emf.ecore.EPackage)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 Display (org.eclipse.swt.widgets.Display)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1