Search in sources :

Example 6 with EnumerationType

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;
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) PropertyAssociation(org.osate.aadl2.PropertyAssociation) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 7 with EnumerationType

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;
}
Also used : EnumerationType(org.osate.aadl2.EnumerationType) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 8 with EnumerationType

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();
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) EObject(org.eclipse.emf.ecore.EObject) ListValue(org.osate.aadl2.ListValue) EnumerationType(org.osate.aadl2.EnumerationType) NamedValue(org.osate.aadl2.NamedValue) PropertyType(org.osate.aadl2.PropertyType) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyConstant(org.osate.aadl2.PropertyConstant)

Aggregations

EnumerationType (org.osate.aadl2.EnumerationType)6 BasicProperty (org.osate.aadl2.BasicProperty)5 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)5 Property (org.osate.aadl2.Property)5 NamedElement (org.osate.aadl2.NamedElement)4 PropertyAssociation (org.osate.aadl2.PropertyAssociation)4 PropertyType (org.osate.aadl2.PropertyType)4 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)3 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)3 ListValue (org.osate.aadl2.ListValue)3 NamedValue (org.osate.aadl2.NamedValue)3 PropertyConstant (org.osate.aadl2.PropertyConstant)3 PropertyExpression (org.osate.aadl2.PropertyExpression)3 RecordType (org.osate.aadl2.RecordType)3 BehaviorElement (org.osate.ba.aadlba.BehaviorElement)3 AadlBoolean (org.osate.aadl2.AadlBoolean)2 AadlInteger (org.osate.aadl2.AadlInteger)2 AadlReal (org.osate.aadl2.AadlReal)2 AadlString (org.osate.aadl2.AadlString)2 BooleanLiteral (org.osate.aadl2.BooleanLiteral)2