Search in sources :

Example 6 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class Aadl2LabelProvider method text.

String text(PropertyExpression pe) {
    if (pe instanceof BooleanLiteral) {
        return "boolean " + ((BooleanLiteral) pe).getValue() + "";
    }
    if (pe instanceof RealLiteral) {
        return "real " + ((RealLiteral) pe).getValue() + "";
    }
    if (pe instanceof IntegerLiteral) {
        return text((IntegerLiteral) pe);
    }
    if (pe instanceof StringLiteral) {
        return text((StringLiteral) pe);
    }
    if (pe instanceof NamedValue) {
        return text((NamedValue) pe);
    }
    if (pe instanceof ReferenceValue) {
        ReferenceValue rv = ((ReferenceValue) pe);
        List<ContainmentPathElement> cpe = rv.getContainmentPathElements();
        return "reference " + cpe.get(0).getNamedElement().getName();
    }
    if (pe instanceof RangeValue) {
        return text(((RangeValue) pe));
    }
    if (pe instanceof ListValue) {
        return text(((ListValue) pe));
    }
    if (pe instanceof RecordValue) {
        return text(((RecordValue) pe));
    }
    // OsateDebug.osateDebug("unknown pe=" + pe);
    return null;
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) BooleanLiteral(org.osate.aadl2.BooleanLiteral) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) NamedValue(org.osate.aadl2.NamedValue) IntegerLiteral(org.osate.aadl2.IntegerLiteral) RangeValue(org.osate.aadl2.RangeValue)

Example 7 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class PropertyUtils method createEnumValue.

/**
 * Create a enumeration value from an enumeration literal.
 *
 * @param literal The enumeration literal
 * @return An enumeration value for the given literal
 * @throws IllegalArgumentException Thrown if literal is null
 */
public static NamedValue createEnumValue(EnumerationLiteral literal) throws IllegalArgumentException {
    if (literal == null) {
        throw new IllegalArgumentException("Enumeration literal is null.");
    }
    NamedValue newPropertyValue = Aadl2Factory.eINSTANCE.createNamedValue();
    newPropertyValue.setNamedValue(literal);
    return newPropertyValue;
}
Also used : NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue)

Example 8 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GeneratedUnits method toPropertyExpression.

default NamedValue toPropertyExpression(ResourceSet resourceSet) {
    NamedValue value = Aadl2Factory.eINSTANCE.createNamedValue();
    value.setNamedValue(toUnitLiteral(resourceSet));
    return value;
}
Also used : NamedValue(org.osate.aadl2.NamedValue)

Example 9 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GetProperties method getAllowedDispatchProtocol.

public static List<EnumerationLiteral> getAllowedDispatchProtocol(NamedElement ne) {
    try {
        List<EnumerationLiteral> res = new ArrayList<>();
        Property allowedDispatchProtocol = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_DISPATCH_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(allowedDispatchProtocol);
        for (PropertyExpression propertyExpression : propertyValues) {
            res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 10 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class AbstractPropertiesSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

NamedValue (org.osate.aadl2.NamedValue)41 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)29 Property (org.osate.aadl2.Property)27 PropertyExpression (org.osate.aadl2.PropertyExpression)24 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)20 PropertyAssociation (org.osate.aadl2.PropertyAssociation)18 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)15 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)15 ListValue (org.osate.aadl2.ListValue)15 StringLiteral (org.osate.aadl2.StringLiteral)15 BasicProperty (org.osate.aadl2.BasicProperty)13 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)13 IntegerLiteral (org.osate.aadl2.IntegerLiteral)12 BooleanLiteral (org.osate.aadl2.BooleanLiteral)11 ClassifierValue (org.osate.aadl2.ClassifierValue)11 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)11 NamedElement (org.osate.aadl2.NamedElement)11 RangeValue (org.osate.aadl2.RangeValue)11 RealLiteral (org.osate.aadl2.RealLiteral)11 RecordValue (org.osate.aadl2.RecordValue)11