use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class AadlBaUtils method getPropertyType.
/**
* Returns the PropertyType object associated to the given PropertyElementHolder
* given object.
* @param holder the PropertyElementHolder given object
* @return the associated PropertyType object
*/
public static PropertyType getPropertyType(PropertyElementHolder holder) {
PropertyType result = null;
Element el = holder.getElement();
if (el instanceof PropertyType) {
result = (PropertyType) el;
} else if (el instanceof BasicProperty) {
result = ((BasicProperty) el).getPropertyType();
} else if (el instanceof PropertyAssociation) {
result = ((PropertyAssociation) el).getProperty().getPropertyType();
} else if (el instanceof PropertyExpression) {
result = PropertyUtils.getContainingProperty((PropertyExpression) el).getPropertyType();
} else if (el instanceof EnumerationLiteral) {
result = (EnumerationType) el.eContainer();
}
return result;
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class AadlBaNameResolver method classifierPropertyReferenceResolver.
// return result code:
// 0 : resolution has passed.
// 1 : classifier is not found.
// 2 : classifier has been found but one or more property names are not found.
private short classifierPropertyReferenceResolver(DeclarativePropertyReference ref, boolean hasToReport) {
if (qualifiedNamedElementResolver(ref.getQualifiedName(), hasToReport)) {
NamedElement klass = (NamedElement) ref.getQualifiedName().getOsateRef();
Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
PropertyAssociation pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), klass);
if (pa != null) {
ref.getPropertyNames().get(0).setOsateRef(pa);
propertyNameId.setOsateRef(pa);
return (short) ((propertyNameResolver(ref.getPropertyNames())) ? 0 : 2);
} else {
reportNameError(propertyNameId, propertyNameId.getId());
return 2;
}
} else {
return 1;
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class AadlBaNameResolver method classifierFeaturePropertyReferenceResolver.
private boolean classifierFeaturePropertyReferenceResolver(DeclarativePropertyReference ref) {
Reference component = ref.getReference();
if (refResolver(component)) {
PropertyAssociation pa = null;
Classifier type = null;
Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
Element el = (component.getOsateRef() != null) ? component.getOsateRef() : component.getBaRef();
if (el instanceof PrototypeBinding) {
PrototypeBinding pb = (PrototypeBinding) el;
type = AadlBaUtils.getClassifier(pb, pb.getContainingClassifier());
} else if (el instanceof ClassifierFeature) {
ClassifierFeature cf = (ClassifierFeature) el;
// Fetch the own property association of the classifier feature.
pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), cf);
if (pa == null) {
type = AadlBaUtils.getClassifier(cf, cf.getContainingClassifier());
}
} else if (el instanceof BehaviorVariable) {
BehaviorVariable bv = (BehaviorVariable) el;
DeclarativeBehaviorElement de = (DeclarativeBehaviorElement) bv.getDataClassifier();
if (de.getOsateRef() instanceof Classifier) {
type = (Classifier) de.getOsateRef();
}
} else // Cannot resolve or unimplemented cases.
{
String msg = "the type of \'" + ((NamedElement) el).getName() + "\' cannot be resolved";
_errManager.error(el, msg);
}
// search within its type.
if (pa == null && type != null) {
pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), type);
}
if (pa != null) {
ref.getPropertyNames().get(0).setOsateRef(pa);
propertyNameId.setOsateRef(pa);
return propertyNameResolver(ref.getPropertyNames());
} else {
reportNameError(propertyNameId, propertyNameId.getId());
return false;
}
} else {
// refResolver has already reported the error.
return false;
}
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class AadlBaTypeChecker method propertyElementHolderResolver.
private PropertyElementHolder propertyElementHolderResolver(Element el, LocationReference loc) {
PropertyElementHolder result = null;
if (el instanceof BasicProperty) {
BasicProperty bp = (BasicProperty) el;
BasicPropertyHolder tmp = _fact.createBasicPropertyHolder();
tmp.setBasicProperty(bp);
result = tmp;
} else if (el instanceof PropertyAssociation) {
PropertyAssociation pa = (PropertyAssociation) el;
PropertyAssociationHolder tmp = _fact.createPropertyAssociationHolder();
tmp.setPropertyAssociation(pa);
result = tmp;
} else if (el instanceof PropertyExpression) {
PropertyExpression pe = (PropertyExpression) el;
PropertyExpressionHolder tmp = _fact.createPropertyExpressionHolder();
tmp.setPropertyExpression(pe);
result = tmp;
} else if (el instanceof PropertyType) {
PropertyType pt = (PropertyType) el;
PropertyTypeHolder tmp = _fact.createPropertyTypeHolder();
tmp.setPropertyType(pt);
result = tmp;
} else if (el instanceof EnumerationLiteral) {
EnumerationLiteral enumLit = (EnumerationLiteral) el;
EnumLiteralHolder tmp = _fact.createEnumLiteralHolder();
tmp.setEnumLiteral(enumLit);
result = tmp;
} else {
String errorMsg = "type: " + el.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
result.setLocationReference(loc);
return result;
}
use of org.osate.aadl2.PropertyAssociation in project osate2 by osate.
the class DeclarativeUtils method unparseElement.
public static String unparseElement(Element el) {
String result;
if (el instanceof PropertyAssociation) {
PropertyAssociation pa = (PropertyAssociation) el;
result = "";
for (ModalPropertyValue mpv : pa.getOwnedValues()) {
result += mpv.getOwnedValue().toString() + " ; ";
}
} else {
result = el.toString();
}
return result;
}
Aggregations