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;
}
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;
}
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));
}
}
}
}
}
}
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;
}
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);
}
}
Aggregations