use of org.osate.aadl2.PropertyConstant in project osate2 by osate.
the class ValidateConnectionsSwitch method classifiersFoundInSupportedTypeConversionsProperty.
// XXX How can I avoid duplicating this method for the instance and the declarative models?
private boolean classifiersFoundInSupportedTypeConversionsProperty(ConnectionInstance connection, Classifier source, Classifier destination) {
PropertyConstant conversionsPropertyConstant = GetProperties.lookupPropertyConstant(connection, AadlProject.SUPPORTED_TYPE_CONVERSIONS);
if (conversionsPropertyConstant == null) {
return false;
}
PropertyExpression constantValue = conversionsPropertyConstant.getConstantValue();
if (!(constantValue instanceof ListValue)) {
return false;
}
for (PropertyExpression classifierPair : ((ListValue) constantValue).getOwnedListElements()) {
if (classifierPair instanceof ListValue) {
EList<PropertyExpression> innerListElements = ((ListValue) classifierPair).getOwnedListElements();
if (innerListElements.size() == 2 && innerListElements.get(0) instanceof ClassifierValue && innerListElements.get(1) instanceof ClassifierValue) {
Classifier firstPairElement = ((ClassifierValue) innerListElements.get(0)).getClassifier();
Classifier secondPairElement = ((ClassifierValue) innerListElements.get(1)).getClassifier();
if (firstPairElement == source && secondPairElement == destination) {
return true;
}
}
}
}
return false;
}
use of org.osate.aadl2.PropertyConstant in project osate2 by osate.
the class ErrorCodeValueImpl method setConstant.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setConstant(PropertyConstant newConstant) {
PropertyConstant oldConstant = constant;
constant = newConstant;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ErrorModelPackage.ERROR_CODE_VALUE__CONSTANT, oldConstant, constant));
}
use of org.osate.aadl2.PropertyConstant in project AGREE by loonwerks.
the class AgreeTypeSystem method inferPropExp.
private static TypeDef inferPropExp(PropertyExpression pe) {
if (pe instanceof IntegerLiteral) {
return Prim.IntTypeDef;
} else if (pe instanceof RealLiteral) {
return Prim.RealTypeDef;
} else if (pe instanceof NamedValue) {
NamedValue nv = (NamedValue) pe;
AbstractNamedValue anv = nv.getNamedValue();
if (anv instanceof PropertyConstant) {
return inferPropExp(((PropertyConstant) anv).getConstantValue());
}
}
return Prim.ErrorTypeDef;
}
use of org.osate.aadl2.PropertyConstant in project AGREE by loonwerks.
the class AgreeValidator method checkGetPropertyExpr.
@Check(CheckType.FAST)
public void checkGetPropertyExpr(GetPropertyExpr getPropExpr) {
ComponentRef componentRef = getPropExpr.getComponentRef();
NamedElement prop = getPropExpr.getProp();
if (!(prop instanceof Property || prop instanceof PropertyConstant)) {
error(getPropExpr.getProp(), "Expected AADL property or property constant");
}
if (prop instanceof Property) {
NamedElement element = namedElementFromComponentRef(componentRef);
final boolean applies = element.acceptsProperty((Property) prop);
if (!applies) {
error("Property " + ((Property) prop).getQualifiedName() + " does not apply to " + element.getQualifiedName() + ".", getPropExpr, AgreePackage.Literals.GET_PROPERTY_EXPR__PROP);
}
}
}
Aggregations