Search in sources :

Example 46 with StringLiteral

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

the class AbstractErrorModelSemanticSequencer 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;
        }
    else if (epackage == ErrorModelPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case ErrorModelPackage.ALL_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getAllExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_AllExpression(context, (AllExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSAllExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SAllExpression(context, (AllExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.AND_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_AndExpression(context, (AndExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SAndExpression(context, (AndExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.BRANCH_VALUE:
                sequence_BranchValue(context, (BranchValue) semanticObject);
                return;
            case ErrorModelPackage.COMPOSITE_STATE:
                sequence_CompositeState(context, (CompositeState) semanticObject);
                return;
            case ErrorModelPackage.CONDITION_ELEMENT:
                sequence_ConditionElement(context, (ConditionElement) semanticObject);
                return;
            case ErrorModelPackage.EMV2_PATH:
                if (rule == grammarAccess.getBasicEMV2PathRule()) {
                    sequence_BasicEMV2Path(context, (EMV2Path) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PathRule()) {
                    sequence_EMV2Path(context, (EMV2Path) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_PATH_ELEMENT:
                if (rule == grammarAccess.getEMV2ErrorPropagationPathRule()) {
                    sequence_EMV2ErrorPropagationPath(context, (EMV2PathElement) semanticObject);
                    return;
                } else if (rule == grammarAccess.getEMV2PathElementOrKindRule()) {
                    sequence_EMV2PathElementOrKind(context, (EMV2PathElement) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PathElementRule()) {
                    sequence_EMV2PathElement(context, (EMV2PathElement) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicEMV2PropertyAssociationRule()) {
                    sequence_BasicEMV2PropertyAssociation(context, (EMV2PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getEMV2PropertyAssociationRule()) {
                    sequence_EMV2PropertyAssociation(context, (EMV2PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.EMV2_ROOT:
                sequence_EMV2Root(context, (EMV2Root) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_STATE:
                sequence_ErrorBehaviorState(context, (ErrorBehaviorState) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_STATE_MACHINE:
                sequence_ErrorBehaviorStateMachine(context, (ErrorBehaviorStateMachine) semanticObject);
                return;
            case ErrorModelPackage.ERROR_BEHAVIOR_TRANSITION:
                sequence_ErrorBehaviorTransition(context, (ErrorBehaviorTransition) semanticObject);
                return;
            case ErrorModelPackage.ERROR_CODE_VALUE:
                sequence_ErrorCodeValue(context, (ErrorCodeValue) semanticObject);
                return;
            case ErrorModelPackage.ERROR_DETECTION:
                sequence_ErrorDetection(context, (ErrorDetection) semanticObject);
                return;
            case ErrorModelPackage.ERROR_EVENT:
                sequence_ErrorEvent(context, (ErrorEvent) semanticObject);
                return;
            case ErrorModelPackage.ERROR_MODEL_LIBRARY:
                if (rule == grammarAccess.getEMV2LibraryRule()) {
                    sequence_EMV2Library(context, (ErrorModelLibrary) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAnnexLibraryRule() || rule == grammarAccess.getNamedElementRule() || rule == grammarAccess.getErrorModelLibraryRule()) {
                    sequence_ErrorModelLibrary(context, (ErrorModelLibrary) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ERROR_MODEL_SUBCLAUSE:
                if (rule == grammarAccess.getEMV2SubclauseRule()) {
                    sequence_EMV2Subclause(context, (ErrorModelSubclause) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAnnexSubclauseRule() || rule == grammarAccess.getModalElementRule() || rule == grammarAccess.getErrorModelSubclauseRule()) {
                    sequence_ErrorModelSubclause(context, (ErrorModelSubclause) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ERROR_PATH:
                sequence_ErrorPath(context, (ErrorPath) semanticObject);
                return;
            case ErrorModelPackage.ERROR_PROPAGATION:
                sequence_ErrorPropagation(context, (ErrorPropagation) semanticObject);
                return;
            case ErrorModelPackage.ERROR_SINK:
                sequence_ErrorSink(context, (ErrorSink) semanticObject);
                return;
            case ErrorModelPackage.ERROR_SOURCE:
                sequence_ErrorSource(context, (ErrorSource) semanticObject);
                return;
            case ErrorModelPackage.ERROR_STATE_TO_MODE_MAPPING:
                sequence_ErrorStateToModeMapping(context, (ErrorStateToModeMapping) semanticObject);
                return;
            case ErrorModelPackage.ERROR_TYPE:
                sequence_TypeDefinition(context, (ErrorType) semanticObject);
                return;
            case ErrorModelPackage.FEATUREOR_PP_REFERENCE:
                sequence_FeatureorPPReference(context, (FeatureorPPReference) semanticObject);
                return;
            case ErrorModelPackage.IF_CONDITION:
                sequence_IfCondition(context, (IfCondition) semanticObject);
                return;
            case ErrorModelPackage.OR_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_ConditionExpression(context, (OrExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SConditionExpression(context, (OrExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ORLESS_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getOrlessExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_OrlessExpression(context, (OrlessExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSOrlessExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SOrlessExpression(context, (OrlessExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.ORMORE_EXPRESSION:
                if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getConditionExpressionRule() || action == grammarAccess.getConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getAndExpressionRule() || action == grammarAccess.getAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getOrmoreExpressionRule() || rule == grammarAccess.getConditionTermRule()) {
                    sequence_OrmoreExpression(context, (OrmoreExpression) semanticObject);
                    return;
                } else if (rule == grammarAccess.getSConditionExpressionRule() || action == grammarAccess.getSConditionExpressionAccess().getOrExpressionOperandsAction_1_0() || rule == grammarAccess.getSAndExpressionRule() || action == grammarAccess.getSAndExpressionAccess().getAndExpressionOperandsAction_1_0() || rule == grammarAccess.getSOrmoreExpressionRule() || rule == grammarAccess.getSConditionTermRule()) {
                    sequence_SOrmoreExpression(context, (OrmoreExpression) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.OUTGOING_PROPAGATION_CONDITION:
                sequence_OutgoingPropagationCondition(context, (OutgoingPropagationCondition) semanticObject);
                return;
            case ErrorModelPackage.PROPAGATION_PATH:
                sequence_PropagationPath(context, (PropagationPath) semanticObject);
                return;
            case ErrorModelPackage.PROPAGATION_POINT:
                sequence_PropagationPoint(context, (PropagationPoint) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_BEHAVIOR_STATE:
                sequence_QualifiedErrorBehaviorState(context, (QualifiedErrorBehaviorState) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_EVENT_OR_PROPAGATION:
                sequence_QualifiedErrorEventOrPropagation(context, (QualifiedErrorEventOrPropagation) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_ERROR_PROPAGATION:
                sequence_QualifiedErrorPropagation(context, (QualifiedErrorPropagation) semanticObject);
                return;
            case ErrorModelPackage.QUALIFIED_PROPAGATION_POINT:
                sequence_QualifiedPropagationPoint(context, (QualifiedPropagationPoint) semanticObject);
                return;
            case ErrorModelPackage.RECOVER_EVENT:
                sequence_RecoverEvent(context, (RecoverEvent) semanticObject);
                return;
            case ErrorModelPackage.REPAIR_EVENT:
                sequence_RepairEvent(context, (RepairEvent) semanticObject);
                return;
            case ErrorModelPackage.REPORTING_PORT_REFERENCE:
                sequence_ReportingPortReference(context, (ReportingPortReference) semanticObject);
                return;
            case ErrorModelPackage.SCONDITION_ELEMENT:
                sequence_SConditionElement(context, (SConditionElement) semanticObject);
                return;
            case ErrorModelPackage.SUBCOMPONENT_ELEMENT:
                sequence_SubcomponentElement(context, (SubcomponentElement) semanticObject);
                return;
            case ErrorModelPackage.TRANSITION_BRANCH:
                sequence_TransitionBranch(context, (TransitionBranch) semanticObject);
                return;
            case ErrorModelPackage.TYPE_MAPPING:
                sequence_TypeMapping(context, (TypeMapping) semanticObject);
                return;
            case ErrorModelPackage.TYPE_MAPPING_SET:
                sequence_TypeMappingSet(context, (TypeMappingSet) semanticObject);
                return;
            case ErrorModelPackage.TYPE_SET:
                if (rule == grammarAccess.getNoErrorTypeSetRule()) {
                    sequence_NoErrorTypeSet(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeTokenOrNoErrorRule() || rule == grammarAccess.getTypeTokenConstraintNoErrorRule()) {
                    sequence_NoErrorTypeSet_TypeSetConstructor(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeSetConstructorRule() || rule == grammarAccess.getTypeSetReferenceRule() || rule == grammarAccess.getTypeTokenRule() || rule == grammarAccess.getTypeTokenConstraintRule()) {
                    sequence_TypeSetConstructor(context, (TypeSet) semanticObject);
                    return;
                } else if (rule == grammarAccess.getNamedElementRule() || rule == grammarAccess.getErrorTypesRule() || rule == grammarAccess.getTypeSetDefinitionRule()) {
                    sequence_TypeSetDefinition(context, (TypeSet) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.TYPE_TOKEN:
                if (rule == grammarAccess.getNoErrorTypeTokenRule()) {
                    sequence_NoErrorTypeToken(context, (TypeToken) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule() || rule == grammarAccess.getTypeSetElementRule()) {
                    sequence_TypeSetElement(context, (TypeToken) semanticObject);
                    return;
                } else
                    break;
            case ErrorModelPackage.TYPE_TRANSFORMATION:
                sequence_TypeTransformation(context, (TypeTransformation) semanticObject);
                return;
            case ErrorModelPackage.TYPE_TRANSFORMATION_SET:
                sequence_TypeTransformationSet(context, (TypeTransformationSet) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) 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) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) BooleanLiteral(org.osate.aadl2.BooleanLiteral) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) OrlessExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrlessExpression) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) IntegerLiteral(org.osate.aadl2.IntegerLiteral) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) StringLiteral(org.osate.aadl2.StringLiteral) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) Parameter(org.eclipse.xtext.Parameter) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement)

Example 47 with StringLiteral

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

the class PropertyValueFormatter method appendPropertyValue.

@SuppressWarnings("unchecked")
public static void appendPropertyValue(final BusinessObjectContext q, final Object value, final boolean expandComplexValues, final StringBuilder sb) {
    if (value instanceof List) {
        if (expandComplexValues) {
            sb.append('(');
            boolean isFirst = true;
            for (final Object element : (List<Object>) value) {
                if (!isFirst) {
                    sb.append(", ");
                }
                isFirst = false;
                appendPropertyValue(q, element, expandComplexValues, sb);
            }
            sb.append(')');
        } else {
            sb.append("<list>");
        }
    } else {
        if (value instanceof BooleanLiteral) {
            final BooleanLiteral bl = (BooleanLiteral) value;
            sb.append(bl.getValue() ? "true" : "false");
        } else if (value instanceof ClassifierValue) {
            final ClassifierValue cv = (ClassifierValue) value;
            sb.append(cv.getClassifier() == null ? "<error>" : cv.getClassifier().getQualifiedName());
        } else if (value instanceof ComputedValue) {
            final ComputedValue cv = (ComputedValue) value;
            sb.append(cv.getFunction());
        } else if (value instanceof NamedValue) {
            final NamedValue nv = (NamedValue) value;
            if (nv.getNamedValue() == null) {
                sb.append("<null>");
            } else {
                appendPropertyValue(q, nv.getNamedValue(), expandComplexValues, sb);
            }
        } else if (value instanceof AbstractNamedValue) {
            final AbstractNamedValue anv = (AbstractNamedValue) value;
            sb.append(anv instanceof NamedElement ? ((NamedElement) anv).getName() : "<error>");
        } else if (value instanceof IntegerLiteral) {
            final IntegerLiteral il = (IntegerLiteral) value;
            sb.append(il.getValue());
            if (il.getUnit() != null) {
                sb.append(' ');
                sb.append(il.getUnit().getName());
            }
        } else if (value instanceof RealLiteral) {
            final RealLiteral rl = (RealLiteral) value;
            sb.append(rl.getValue());
            if (rl.getUnit() != null) {
                sb.append(' ');
                sb.append(rl.getUnit().getName());
            }
        } else if (value instanceof RangeValue) {
            final RangeValue rv = (RangeValue) value;
            appendPropertyValue(q, rv.getMinimum(), expandComplexValues, sb);
            sb.append(" .. ");
            appendPropertyValue(q, rv.getMaximum(), expandComplexValues, sb);
            if (rv.getDeltaValue() != null) {
                sb.append("delta ");
                appendPropertyValue(q, rv.getDelta(), expandComplexValues, sb);
            }
        } else if (value instanceof RecordValue) {
            final RecordValue rv = (RecordValue) value;
            if (expandComplexValues) {
                sb.append('[');
                for (final BasicPropertyAssociation bpa : rv.getOwnedFieldValues()) {
                    sb.append(bpa.getProperty() == null ? "<UnknownField>" : bpa.getProperty().getName());
                    sb.append(" => ");
                    appendPropertyValue(q, bpa.getValue(), expandComplexValues, sb);
                    sb.append("; ");
                }
                sb.append(']');
            } else {
                sb.append("<record>");
            }
        } else if (value instanceof StringLiteral) {
            final StringLiteral sl = (StringLiteral) value;
            sb.append('"');
            sb.append(sl.getValue());
            sb.append('"');
        } else if (value instanceof ReferenceValueWithContext) {
            final ReferenceValueWithContext rv = (ReferenceValueWithContext) value;
            BusinessObjectContext tmp = q;
            for (int i = 0; i < rv.propertyAssociationOwnerAncestorLevel; i++) {
                tmp = tmp.getParent();
                if (tmp == null) {
                    return;
                }
            }
            // The reference is relative to the current value of tmp
            // Append Each Level Until Reaching the Containing Classifier
            String prefix = null;
            while (tmp != null && tmp.getBusinessObject() instanceof NamedElement && !(tmp.getBusinessObject() instanceof Classifier)) {
                final String containerName = ((NamedElement) tmp.getBusinessObject()).getName();
                if (containerName == null) {
                    // Ignore
                    return;
                }
                if (prefix == null) {
                    prefix = containerName;
                } else {
                    prefix = containerName + "." + prefix;
                }
                tmp = tmp.getParent();
            }
            // Handle relative portion.. need to add appropriate ancestors.
            if (prefix != null) {
                sb.append(prefix);
            }
            boolean isFirst = prefix == null;
            for (ContainmentPathElement pathElement = rv.referenceValue.getPath(); pathElement != null; pathElement = pathElement.getPath()) {
                if (!isFirst) {
                    sb.append(".");
                }
                isFirst = false;
                final NamedElement ne = pathElement.getNamedElement();
                if (ne == null) {
                    sb.append("<null>");
                } else {
                    sb.append(ne.getName());
                }
                for (final ArrayRange ar : pathElement.getArrayRanges()) {
                    sb.append('[');
                    sb.append(ar.getLowerBound());
                    if (ar.getUpperBound() > 0) {
                        sb.append(" .. ");
                        sb.append(ar.getUpperBound());
                    }
                    sb.append(']');
                }
            }
        } else if (value instanceof InstanceReferenceValue) {
            final InstanceReferenceValue irv = (InstanceReferenceValue) value;
            if (irv.getReferencedInstanceObject() != null) {
                sb.append(irv.getReferencedInstanceObject().getComponentInstancePath());
            } else {
                sb.append("?");
            }
        } else if (value instanceof EObject) {
            final INode n = NodeModelUtils.getNode((EObject) value);
            if (n != null) {
                final String txt = NodeModelUtils.getTokenText(n);
                if (txt != null) {
                    sb.append(txt);
                    return;
                }
            }
            sb.append("<Unable to Retrieve>");
        } else {
            sb.append("<Unsupported Value Type>");
        }
    }
}
Also used : ComputedValue(org.osate.aadl2.ComputedValue) INode(org.eclipse.xtext.nodemodel.INode) ClassifierValue(org.osate.aadl2.ClassifierValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Classifier(org.osate.aadl2.Classifier) RangeValue(org.osate.aadl2.RangeValue) RealLiteral(org.osate.aadl2.RealLiteral) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) IntegerLiteral(org.osate.aadl2.IntegerLiteral) RecordValue(org.osate.aadl2.RecordValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) StringLiteral(org.osate.aadl2.StringLiteral) EObject(org.eclipse.emf.ecore.EObject) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) NamedElement(org.osate.aadl2.NamedElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 48 with StringLiteral

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

the class AbstractInstanceSemanticSequencer 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;
        }
    else if (epackage == InstancePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case InstancePackage.COMPONENT_INSTANCE:
                sequence_ComponentInstance(context, (ComponentInstance) semanticObject);
                return;
            case InstancePackage.CONNECTION_INSTANCE:
                sequence_ConnectionInstance(context, (ConnectionInstance) semanticObject);
                return;
            case InstancePackage.CONNECTION_REFERENCE:
                sequence_ConnectionReference(context, (ConnectionReference) semanticObject);
                return;
            case InstancePackage.END_TO_END_FLOW_INSTANCE:
                sequence_EndToEndFlowInstance(context, (EndToEndFlowInstance) semanticObject);
                return;
            case InstancePackage.FEATURE_INSTANCE:
                sequence_FeatureInstance(context, (FeatureInstance) semanticObject);
                return;
            case InstancePackage.FLOW_SPECIFICATION_INSTANCE:
                sequence_FlowSpecificationInstance(context, (FlowSpecificationInstance) semanticObject);
                return;
            case InstancePackage.INSTANCE_REFERENCE_VALUE:
                sequence_InstanceReferenceValue(context, (InstanceReferenceValue) semanticObject);
                return;
            case InstancePackage.MODE_INSTANCE:
                sequence_ModeInstance(context, (ModeInstance) semanticObject);
                return;
            case InstancePackage.MODE_TRANSITION_INSTANCE:
                sequence_ModeTransitionInstance(context, (ModeTransitionInstance) semanticObject);
                return;
            case InstancePackage.PROPERTY_ASSOCIATION_INSTANCE:
                sequence_PropertyAssociationInstance(context, (PropertyAssociationInstance) semanticObject);
                return;
            case InstancePackage.SYSTEM_INSTANCE:
                sequence_SystemInstance(context, (SystemInstance) semanticObject);
                return;
            case InstancePackage.SYSTEM_OPERATION_MODE:
                sequence_SystemOperationMode(context, (SystemOperationMode) 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) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) 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)

Example 49 with StringLiteral

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

the class Arinc653 method getPartitionName.

public static Optional<String> getPartitionName(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getPartitionName_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((StringLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 50 with StringLiteral

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

the class Arinc653 method getModuleIdentifier.

public static Optional<String> getModuleIdentifier(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getModuleIdentifier_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((StringLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

StringLiteral (org.osate.aadl2.StringLiteral)42 PropertyExpression (org.osate.aadl2.PropertyExpression)37 Property (org.osate.aadl2.Property)32 ListValue (org.osate.aadl2.ListValue)24 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)19 BooleanLiteral (org.osate.aadl2.BooleanLiteral)18 IntegerLiteral (org.osate.aadl2.IntegerLiteral)17 RealLiteral (org.osate.aadl2.RealLiteral)17 NamedValue (org.osate.aadl2.NamedValue)16 RecordValue (org.osate.aadl2.RecordValue)14 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)13 ClassifierValue (org.osate.aadl2.ClassifierValue)13 RangeValue (org.osate.aadl2.RangeValue)12 PropertyAssociation (org.osate.aadl2.PropertyAssociation)11 EPackage (org.eclipse.emf.ecore.EPackage)10 Action (org.eclipse.xtext.Action)10 Parameter (org.eclipse.xtext.Parameter)10 ParserRule (org.eclipse.xtext.ParserRule)10 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)10 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)10