use of org.osate.aadl2.EnumerationType 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.EnumerationType in project osate2 by osate.
the class AadlBaNameResolver method enumerationTypeResolver.
private boolean enumerationTypeResolver(EnumerationType type, DeclarativePropertyName declPropertyName) {
EnumerationType enumType = type;
for (EnumerationLiteral literal : enumType.getOwnedLiterals()) {
if (literal.getName().equalsIgnoreCase(declPropertyName.getPropertyName().getId())) {
declPropertyName.setOsateRef(literal);
declPropertyName.getPropertyName().setOsateRef(literal);
return true;
}
}
return false;
}
use of org.osate.aadl2.EnumerationType in project osate2 by osate.
the class PropertiesLinkingService method findEnumLiteralAsList.
public static List<EObject> findEnumLiteralAsList(EObject context, EReference reference, String name) {
// look for enumeration literal
if (context instanceof NamedValue) {
NamedValue value = (NamedValue) context;
EObject owner = value.getOwner();
while (owner instanceof ListValue) {
owner = owner.eContainer();
}
PropertyType propertyType = null;
if (// Value of the property
owner instanceof PropertyConstant) // constant.
{
// TODO: Need to check that the type of the property
// constant is correct for the value.
// We should do this when the type of the constant is
// resolved in PropertyTypeReference.
propertyType = ((PropertyConstant) owner).getPropertyType();
} else if (// Default value of a
owner instanceof Property) // property definition.
{
// TODO: Need to check that the type of the property
// definition is correct for the value.
// We should do this when the type of the definition is
// resolved in PropertyValuePropertyTypeReference.
propertyType = ((Property) owner).getPropertyType();
} else if (// Value
owner instanceof ModalPropertyValue && owner.eContainer() instanceof PropertyAssociation) // of
// an
// association.
{
// TODO: Need to check that the type of the property
// definition is correct for the value.
// We should do this when the definition of the association
// is resolved in PropertyDefinitionReference.
Property p = ((PropertyAssociation) owner.eContainer()).getProperty();
propertyType = p.getPropertyType();
} else if (// Inner
owner instanceof BasicPropertyAssociation) // value
// of a
// record
// value.
{
// TODO: Need to check that the type of the record field is
// correct for the value.
// We should do this when the record field of the record
// value is resolved in PropertyRecordFieldReference.
propertyType = ((BasicPropertyAssociation) owner).getProperty().getPropertyType();
}
propertyType = AadlUtil.getBasePropertyType(propertyType);
if (propertyType != null && propertyType instanceof EnumerationType) {
EnumerationLiteral literal = ((EnumerationType) propertyType).findLiteral(name);
if (literal != null) {
return Collections.singletonList((EObject) literal);
}
}
}
return Collections.<EObject>emptyList();
}
Aggregations