Search in sources :

Example 56 with StringLiteral

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

the class PropertyUtils method createStringValue.

/**
 * Creates a PropertyValue for a string.
 *
 * @throws IllegalArgumentException Thrown if stringValue is null.
 */
public static StringLiteral createStringValue(String stringValue) throws IllegalArgumentException {
    if (stringValue == null) {
        throw new IllegalArgumentException("stringValue cannot be null.");
    }
    StringLiteral newPropertyValue = Aadl2Factory.eINSTANCE.createStringLiteral();
    newPropertyValue.setValue(stringValue);
    return newPropertyValue;
}
Also used : StringLiteral(org.osate.aadl2.StringLiteral)

Example 57 with StringLiteral

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

the class EMV2Properties method getHazardDescription.

public static String getHazardDescription(NamedElement element, NamedElement relatedComponent, ErrorTypes ts) {
    List<EMV2PropertyAssociation> PA = EMV2Properties.getHazardsProperty(relatedComponent, element, ts);
    if (PA.isEmpty()) {
        return null;
    }
    // XXX TODO we may get more than one back, one each for different types
    PropertyExpression val = getPropertyValue(PA.get(0));
    if (val instanceof RecordValue) {
        RecordValue rv = (RecordValue) val;
        EList<BasicPropertyAssociation> fields = rv.getOwnedFieldValues();
        BasicPropertyAssociation xref = GetProperties.getRecordField(fields, "description");
        if (xref != null) {
            PropertyExpression peVal = getPropertyValue(xref);
            if (peVal instanceof StringLiteral) {
                return ((StringLiteral) peVal).getValue();
            }
        }
    }
    if (val instanceof ListValue) {
        ListValue lv = (ListValue) val;
        for (PropertyExpression pe : lv.getOwnedListElements()) {
            if (pe instanceof RecordValue) {
                RecordValue rv = (RecordValue) pe;
                EList<BasicPropertyAssociation> fields = rv.getOwnedFieldValues();
                BasicPropertyAssociation xref = GetProperties.getRecordField(fields, "description");
                if (xref != null) {
                    PropertyExpression peVal = getPropertyValue(xref);
                    if (peVal instanceof StringLiteral) {
                        return ((StringLiteral) peVal).getValue();
                    }
                }
            }
        }
    }
    return null;
}
Also used : StringLiteral(org.osate.aadl2.StringLiteral) ListValue(org.osate.aadl2.ListValue) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) RecordValue(org.osate.aadl2.RecordValue) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation)

Example 58 with StringLiteral

use of org.osate.aadl2.StringLiteral in project AGREE by loonwerks.

the class AgreeTypeSystem method typeDefFromClassifier.

public static TypeDef typeDefFromClassifier(Classifier c) {
    if (c instanceof DataType || (c instanceof DataImplementation && ((DataImplementation) c).getAllSubcomponents().isEmpty() && ((DataImplementation) c).getType() != null)) {
        // Includes special case for data implementations implementing extensions of primitive types
        Classifier classifierType = c instanceof DataImplementation ? ((DataImplementation) c).getType() : c;
        List<PropertyAssociation> pas = classifierType.getAllPropertyAssociations();
        for (Classifier classType : classifierType.getSelfPlusAllExtended()) {
            if (classType != null && hasIntegerDataRepresentation(classType)) {
                for (PropertyAssociation choice : pas) {
                    Property p = choice.getProperty();
                    PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
                    String key = p.getQualifiedName();
                    if (key.equals("Data_Model::Integer_Range")) {
                        if (v instanceof RangeValue) {
                            try {
                                RangeValue rangeValue = (RangeValue) v;
                                long min = intFromPropExp(rangeValue.getMinimum()).get();
                                long max = intFromPropExp(rangeValue.getMaximum()).get();
                                return new RangeIntTypeDef(min, max);
                            } catch (Exception e) {
                                return Prim.ErrorTypeDef;
                            }
                        }
                    }
                }
                return Prim.IntTypeDef;
            } else if (classType != null && hasFloatDataRepresentation(classType)) {
                for (PropertyAssociation choice : pas) {
                    Property p = choice.getProperty();
                    PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
                    String key = p.getQualifiedName();
                    if (key.equals("Data_Model::Real_Range")) {
                        if (v instanceof RangeValue) {
                            try {
                                RangeValue rangeValue = (RangeValue) v;
                                double min = realFromPropExp(rangeValue.getMinimum()).get();
                                double max = realFromPropExp(rangeValue.getMaximum()).get();
                                return new RangeRealTypeDef(min, max);
                            } catch (Exception e) {
                                return Prim.ErrorTypeDef;
                            }
                        }
                    }
                }
                return Prim.RealTypeDef;
            } else if (classType != null && hasBooleanDataRepresentation(classType)) {
                return Prim.BoolTypeDef;
            }
        }
        boolean prop_isArray = false;
        int prop_arraySize = 0;
        TypeDef prop_arrayBaseType = null;
        boolean prop_isEnum = false;
        List<String> prop_enumValues = null;
        for (PropertyAssociation choice : pas) {
            Property p = choice.getProperty();
            PropertyExpression v = choice.getOwnedValues().get(0).getOwnedValue();
            String key = p.getQualifiedName();
            key = key == null ? p.getName() : key;
            if (key == null) {
                return Prim.ErrorTypeDef;
            }
            if (key.equalsIgnoreCase("Data_Model::Data_Representation")) {
                if (v instanceof NamedValue) {
                    AbstractNamedValue anv = ((NamedValue) v).getNamedValue();
                    if (anv instanceof EnumerationLiteral) {
                        EnumerationLiteral el = (EnumerationLiteral) anv;
                        prop_isArray = el.getName().equals("Array");
                        prop_isEnum = el.getName().equals("Enum");
                    }
                }
            } else if (key.equalsIgnoreCase("Data_Model::Enumerators")) {
                if (v instanceof ListValue) {
                    EList<PropertyExpression> peList = ((ListValue) v).getOwnedListElements();
                    String prefix = c.getQualifiedName() + "_";
                    prop_enumValues = new ArrayList<>();
                    for (PropertyExpression pe : peList) {
                        if (pe instanceof StringLiteral) {
                            String enumString = prefix + ((StringLiteral) pe).getValue();
                            prop_enumValues.add(enumString);
                        }
                    }
                }
            } else if (key.equalsIgnoreCase("Data_Model::Base_Type")) {
                if (v instanceof ListValue) {
                    ListValue l = (ListValue) v;
                    PropertyExpression pe = l.getOwnedListElements().get(0);
                    if (pe instanceof ClassifierValue) {
                        prop_arrayBaseType = typeDefFromClassifier(((ClassifierValue) pe).getClassifier());
                    }
                }
            } else if (key.equalsIgnoreCase("Data_Model::Dimension")) {
                if (v instanceof ListValue) {
                    ListValue l = (ListValue) v;
                    PropertyExpression pe = l.getOwnedListElements().get(0);
                    prop_arraySize = Math.toIntExact(intFromPropExp(pe).orElse((long) -1).longValue());
                }
            }
        }
        if (prop_isArray && prop_arraySize > 0 && prop_arrayBaseType != null) {
            return new ArrayTypeDef(prop_arrayBaseType, prop_arraySize, Optional.of(c));
        } else if (prop_isEnum && prop_enumValues != null) {
            String name = c.getQualifiedName();
            return new EnumTypeDef(name, prop_enumValues, c);
        }
    } else if (c instanceof ComponentClassifier) {
        Map<String, TypeDef> fields = new HashMap<>();
        Classifier currClsfr = c;
        while (currClsfr != null) {
            ComponentType ct = null;
            if (currClsfr instanceof ComponentImplementation) {
                EList<Subcomponent> subcomps = ((ComponentImplementation) currClsfr).getAllSubcomponents();
                for (Subcomponent sub : subcomps) {
                    String fieldName = sub.getName();
                    if (sub.getClassifier() != null) {
                        boolean prop_isArray = false;
                        int prop_arraySize = 0;
                        boolean prop_isEnum = false;
                        List<String> prop_enumValues = null;
                        for (PropertyAssociation pa : sub.getOwnedPropertyAssociations()) {
                            Property p = pa.getProperty();
                            String key = p.getQualifiedName();
                            key = key == null ? p.getName() : key;
                            PropertyExpression v = null;
                            if (!pa.getOwnedValues().isEmpty()) {
                                v = pa.getOwnedValues().get(0).getOwnedValue();
                            } else {
                                continue;
                            }
                            if (key.equals("Data_Model::Data_Representation")) {
                                if (v instanceof NamedValue) {
                                    AbstractNamedValue anv = ((NamedValue) v).getNamedValue();
                                    if (anv instanceof EnumerationLiteral) {
                                        EnumerationLiteral el = (EnumerationLiteral) anv;
                                        prop_isArray = el.getName().equals("Array");
                                        prop_isEnum = el.getName().equals("Enum");
                                    }
                                }
                            } else if (key.equals("Data_Model::Dimension")) {
                                if (v instanceof ListValue) {
                                    ListValue l = (ListValue) v;
                                    PropertyExpression pe = l.getOwnedListElements().get(0);
                                    prop_arraySize = Math.toIntExact(intFromPropExp(pe).orElse((long) -1).longValue());
                                }
                            } else if (key.equals("Data_Model::Enumerators")) {
                                if (v instanceof ListValue) {
                                    EList<PropertyExpression> peList = ((ListValue) v).getOwnedListElements();
                                    String prefix = c.getQualifiedName() + "_";
                                    prop_enumValues = new ArrayList<>();
                                    for (PropertyExpression pe : peList) {
                                        if (pe instanceof StringLiteral) {
                                            String enumString = prefix + ((StringLiteral) pe).getValue();
                                            prop_enumValues.add(enumString);
                                        }
                                    }
                                }
                            }
                        }
                        if (prop_isArray && prop_arraySize > 0) {
                            TypeDef typeDef = new ArrayTypeDef(typeDefFromClassifier(sub.getClassifier()), prop_arraySize, Optional.empty());
                            fields.putIfAbsent(fieldName, typeDef);
                        } else if (prop_isEnum && prop_enumValues != null) {
                            String name = c.getQualifiedName();
                            TypeDef typeDef = new EnumTypeDef(name, prop_enumValues, c);
                            fields.putIfAbsent(fieldName, typeDef);
                        } else if (sub.getArrayDimensions().size() == 0) {
                            TypeDef typeDef = typeDefFromClassifier(sub.getClassifier());
                            fields.putIfAbsent(fieldName, typeDef);
                        } else if (sub.getArrayDimensions().size() == 1) {
                            ArrayDimension ad = sub.getArrayDimensions().get(0);
                            int size = Math.toIntExact(getArraySize(ad));
                            TypeDef stem = typeDefFromClassifier(sub.getClassifier());
                            TypeDef typeDef = new ArrayTypeDef(stem, size, Optional.empty());
                            fields.putIfAbsent(fieldName, typeDef);
                        }
                    }
                }
                ct = ((ComponentImplementation) currClsfr).getType();
            } else if (c instanceof ComponentType) {
                ct = (ComponentType) currClsfr;
            }
            if (ct != null) {
                EList<Feature> features = ct.getAllFeatures();
                for (Feature feature : features) {
                    String fieldName = feature.getName();
                    if (feature.getClassifier() != null) {
                        if (feature.getArrayDimensions().size() == 0) {
                            TypeDef typeDef = typeDefFromClassifier(feature.getClassifier());
                            fields.putIfAbsent(fieldName, typeDef);
                        } else if (feature.getArrayDimensions().size() == 1) {
                            ArrayDimension ad = feature.getArrayDimensions().get(0);
                            int size = Math.toIntExact(getArraySize(ad));
                            TypeDef stem = typeDefFromClassifier(feature.getClassifier());
                            TypeDef typeDef = new ArrayTypeDef(stem, size, Optional.empty());
                            fields.putIfAbsent(fieldName, typeDef);
                        }
                    }
                }
                for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(currClsfr, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
                    AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
                    for (SpecStatement spec : contract.getSpecs()) {
                        List<Arg> args = new ArrayList<>();
                        if (spec instanceof EqStatement) {
                            args = ((EqStatement) spec).getLhs();
                        } else if (spec instanceof InputStatement) {
                            args = ((InputStatement) spec).getLhs();
                        }
                        for (Arg arg : args) {
                            String fieldName = arg.getName();
                            TypeDef typeDef = typeDefFromNE(arg);
                            fields.putIfAbsent(fieldName, typeDef);
                        }
                        if (spec instanceof ConstStatement) {
                            String fieldName = ((ConstStatement) spec).getName();
                            TypeDef typeDef = AgreeTypeSystem.typeDefFromType(((ConstStatement) spec).getType());
                            fields.putIfAbsent(fieldName, typeDef);
                        }
                    }
                }
            }
            currClsfr = currClsfr.getExtended();
        }
        String name = c.getQualifiedName();
        return new RecordTypeDef(name, fields, c);
    }
    return Prim.ErrorTypeDef;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ClassifierValue(org.osate.aadl2.ClassifierValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ArrayList(java.util.ArrayList) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) AadlString(org.osate.aadl2.AadlString) Feature(org.osate.aadl2.Feature) RangeValue(org.osate.aadl2.RangeValue) Subcomponent(org.osate.aadl2.Subcomponent) DataType(org.osate.aadl2.DataType) PropertyExpression(org.osate.aadl2.PropertyExpression) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentType(org.osate.aadl2.ComponentType) ListValue(org.osate.aadl2.ListValue) DataImplementation(org.osate.aadl2.DataImplementation) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) EList(org.eclipse.emf.common.util.EList) StringLiteral(org.osate.aadl2.StringLiteral) Arg(com.rockwellcollins.atc.agree.agree.Arg) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) Map(java.util.Map) HashMap(java.util.HashMap) ArrayDimension(org.osate.aadl2.ArrayDimension) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 59 with StringLiteral

use of org.osate.aadl2.StringLiteral in project AGREE by loonwerks.

the class AbstractAgreeSemanticSequencer 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 == AgreePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case AgreePackage.AGREE_CONTRACT:
                sequence_AgreeContract(context, (AgreeContract) semanticObject);
                return;
            case AgreePackage.AGREE_CONTRACT_LIBRARY:
                sequence_AgreeLibrary(context, (AgreeContractLibrary) semanticObject);
                return;
            case AgreePackage.AGREE_CONTRACT_SUBCLAUSE:
                sequence_AgreeSubclause(context, (AgreeContractSubclause) semanticObject);
                return;
            case AgreePackage.ALWAYS_STATEMENT:
                sequence_PatternStatement(context, (AlwaysStatement) semanticObject);
                return;
            case AgreePackage.ARG:
                sequence_Arg(context, (Arg) semanticObject);
                return;
            case AgreePackage.ARRAY_LITERAL_EXPR:
                sequence_ArrayLiteralExpr(context, (ArrayLiteralExpr) semanticObject);
                return;
            case AgreePackage.ARRAY_SUB_EXPR:
                sequence_ArraySubExpr(context, (ArraySubExpr) semanticObject);
                return;
            case AgreePackage.ARRAY_TYPE:
                sequence_Type(context, (ArrayType) semanticObject);
                return;
            case AgreePackage.ARRAY_UPDATE_EXPR:
                sequence_ArrayUpdateExpr(context, (ArrayUpdateExpr) semanticObject);
                return;
            case AgreePackage.ASSERT_STATEMENT:
                sequence_NamedSpecStatement(context, (AssertStatement) semanticObject);
                return;
            case AgreePackage.ASSIGN_STATEMENT:
                sequence_AssignStatement(context, (AssignStatement) semanticObject);
                return;
            case AgreePackage.ASSUME_STATEMENT:
                sequence_NamedSpecStatement(context, (AssumeStatement) semanticObject);
                return;
            case AgreePackage.ASYNCH_STATEMENT:
                sequence_SynchStatement(context, (AsynchStatement) semanticObject);
                return;
            case AgreePackage.BINARY_EXPR:
                sequence_AddSubExpr_AndExpr_ArrowExpr_EquivExpr_ImpliesExpr_MultDivExpr_OrExpr_PowerExpr_RelateExpr(context, (BinaryExpr) semanticObject);
                return;
            case AgreePackage.BOOL_LIT_EXPR:
                sequence_TermExpr(context, (BoolLitExpr) semanticObject);
                return;
            case AgreePackage.CALEN_STATEMENT:
                sequence_SynchStatement(context, (CalenStatement) semanticObject);
                return;
            case AgreePackage.CALL_EXPR:
                sequence_TermExpr(context, (CallExpr) semanticObject);
                return;
            case AgreePackage.CLOSED_TIME_INTERVAL:
                sequence_TimeInterval(context, (ClosedTimeInterval) semanticObject);
                return;
            case AgreePackage.CONNECTION_STATEMENT:
                sequence_SpecStatement(context, (ConnectionStatement) semanticObject);
                return;
            case AgreePackage.CONST_STATEMENT:
                sequence_ConstStatement(context, (ConstStatement) semanticObject);
                return;
            case AgreePackage.DOUBLE_DOT_REF:
                sequence_DoubleDotRef(context, (DoubleDotRef) semanticObject);
                return;
            case AgreePackage.ENUM_LIT_EXPR:
                sequence_TermExpr(context, (EnumLitExpr) semanticObject);
                return;
            case AgreePackage.ENUM_STATEMENT:
                sequence_EnumStatement(context, (EnumStatement) semanticObject);
                return;
            case AgreePackage.EQ_STATEMENT:
                sequence_EqStatement(context, (EqStatement) semanticObject);
                return;
            case AgreePackage.EVENT_EXPR:
                sequence_TermExpr(context, (EventExpr) semanticObject);
                return;
            case AgreePackage.EXISTS_EXPR:
                sequence_ExistsExpr(context, (ExistsExpr) semanticObject);
                return;
            case AgreePackage.FLATMAP_EXPR:
                sequence_FlatmapExpr(context, (FlatmapExpr) semanticObject);
                return;
            case AgreePackage.FLOOR_CAST:
                sequence_TermExpr(context, (FloorCast) semanticObject);
                return;
            case AgreePackage.FN_DEF:
                sequence_FnDef(context, (FnDef) semanticObject);
                return;
            case AgreePackage.FOLD_LEFT_EXPR:
                sequence_FoldLeftExpr(context, (FoldLeftExpr) semanticObject);
                return;
            case AgreePackage.FOLD_RIGHT_EXPR:
                sequence_FoldRightExpr(context, (FoldRightExpr) semanticObject);
                return;
            case AgreePackage.FORALL_EXPR:
                sequence_ForallExpr(context, (ForallExpr) semanticObject);
                return;
            case AgreePackage.GET_PROPERTY_EXPR:
                sequence_PreDefFnExpr(context, (GetPropertyExpr) semanticObject);
                return;
            case AgreePackage.GUARANTEE_STATEMENT:
                sequence_NamedSpecStatement(context, (GuaranteeStatement) semanticObject);
                return;
            case AgreePackage.IF_THEN_ELSE_EXPR:
                sequence_IfThenElseExpr(context, (IfThenElseExpr) semanticObject);
                return;
            case AgreePackage.INDICES_EXPR:
                sequence_TermExpr(context, (IndicesExpr) semanticObject);
                return;
            case AgreePackage.INITIAL_STATEMENT:
                sequence_SpecStatement(context, (InitialStatement) semanticObject);
                return;
            case AgreePackage.INPUT_STATEMENT:
                sequence_InputStatement(context, (InputStatement) semanticObject);
                return;
            case AgreePackage.INT_LIT_EXPR:
                sequence_TermExpr(context, (IntLitExpr) semanticObject);
                return;
            case AgreePackage.LATCHED_EXPR:
                sequence_TermExpr(context, (LatchedExpr) semanticObject);
                return;
            case AgreePackage.LATCHED_STATEMENT:
                sequence_SynchStatement(context, (LatchedStatement) semanticObject);
                return;
            case AgreePackage.LEMMA_STATEMENT:
                sequence_NamedSpecStatement(context, (LemmaStatement) semanticObject);
                return;
            case AgreePackage.LIBRARY_FN_DEF:
                sequence_LibraryFnDef(context, (LibraryFnDef) semanticObject);
                return;
            case AgreePackage.LIFT_CONTRACT_STATEMENT:
                sequence_SpecStatement(context, (LiftContractStatement) semanticObject);
                return;
            case AgreePackage.LINEARIZATION_DEF:
                sequence_LinearizationDef(context, (LinearizationDef) semanticObject);
                return;
            case AgreePackage.LINEARIZATION_INTERVAL:
                sequence_LinearizationInterval(context, (LinearizationInterval) semanticObject);
                return;
            case AgreePackage.MN_SYNCH_STATEMENT:
                sequence_SynchStatement(context, (MNSynchStatement) semanticObject);
                return;
            case AgreePackage.NAMED_ELM_EXPR:
                sequence_TermExpr(context, (NamedElmExpr) semanticObject);
                return;
            case AgreePackage.NAMED_ID:
                sequence_NamedID(context, (NamedID) semanticObject);
                return;
            case AgreePackage.NODE_BODY_EXPR:
                sequence_NodeBodyExpr(context, (NodeBodyExpr) semanticObject);
                return;
            case AgreePackage.NODE_DEF:
                sequence_NodeDef(context, (NodeDef) semanticObject);
                return;
            case AgreePackage.NODE_EQ:
                sequence_NodeStmt(context, (NodeEq) semanticObject);
                return;
            case AgreePackage.NODE_LEMMA:
                sequence_NodeStmt(context, (NodeLemma) semanticObject);
                return;
            case AgreePackage.OPEN_LEFT_TIME_INTERVAL:
                sequence_TimeInterval(context, (OpenLeftTimeInterval) semanticObject);
                return;
            case AgreePackage.OPEN_RIGHT_TIME_INTERVAL:
                sequence_TimeInterval(context, (OpenRightTimeInterval) semanticObject);
                return;
            case AgreePackage.OPEN_TIME_INTERVAL:
                sequence_TimeInterval(context, (OpenTimeInterval) semanticObject);
                return;
            case AgreePackage.ORDER_STATEMENT:
                sequence_OrderStatement(context, (OrderStatement) semanticObject);
                return;
            case AgreePackage.PARAM_STATEMENT:
                sequence_SpecStatement(context, (ParamStatement) semanticObject);
                return;
            case AgreePackage.PERIODIC_STATEMENT:
                sequence_RealTimeStatement(context, (PeriodicStatement) semanticObject);
                return;
            case AgreePackage.PRE_EXPR:
                sequence_TermExpr(context, (PreExpr) semanticObject);
                return;
            case AgreePackage.PREV_EXPR:
                sequence_PreDefFnExpr(context, (PrevExpr) semanticObject);
                return;
            case AgreePackage.PRIM_TYPE:
                sequence_BaseType(context, (PrimType) semanticObject);
                return;
            case AgreePackage.PROPERTY_STATEMENT:
                sequence_PropertyStatement(context, (PropertyStatement) semanticObject);
                return;
            case AgreePackage.REACHABLE_STATEMENT:
                sequence_NamedSpecStatement(context, (ReachableStatement) semanticObject);
                return;
            case AgreePackage.REAL_CAST:
                sequence_TermExpr(context, (RealCast) semanticObject);
                return;
            case AgreePackage.REAL_LIT_EXPR:
                sequence_TermExpr(context, (RealLitExpr) semanticObject);
                return;
            case AgreePackage.RECORD_DEF:
                sequence_RecordDef(context, (RecordDef) semanticObject);
                return;
            case AgreePackage.RECORD_LIT_EXPR:
                sequence_TermExpr(context, (RecordLitExpr) semanticObject);
                return;
            case AgreePackage.RECORD_UPDATE_EXPR:
                sequence_RecordUpdateExpr(context, (RecordUpdateExpr) semanticObject);
                return;
            case AgreePackage.SELECTION_EXPR:
                sequence_SelectionExpr(context, (SelectionExpr) semanticObject);
                return;
            case AgreePackage.SPORADIC_STATEMENT:
                sequence_RealTimeStatement(context, (SporadicStatement) semanticObject);
                return;
            case AgreePackage.SYNCH_STATEMENT:
                sequence_SynchStatement(context, (SynchStatement) semanticObject);
                return;
            case AgreePackage.TAG_EXPR:
                sequence_TagExpr(context, (TagExpr) semanticObject);
                return;
            case AgreePackage.THIS_REF:
                sequence_ComponentRef(context, (ThisRef) semanticObject);
                return;
            case AgreePackage.TIME_EXPR:
                sequence_TermExpr(context, (TimeExpr) semanticObject);
                return;
            case AgreePackage.TIME_FALL_EXPR:
                sequence_TermExpr(context, (TimeFallExpr) semanticObject);
                return;
            case AgreePackage.TIME_OF_EXPR:
                sequence_TermExpr(context, (TimeOfExpr) semanticObject);
                return;
            case AgreePackage.TIME_RISE_EXPR:
                sequence_TermExpr(context, (TimeRiseExpr) semanticObject);
                return;
            case AgreePackage.UNARY_EXPR:
                sequence_UnaryExpr(context, (UnaryExpr) semanticObject);
                return;
            case AgreePackage.UNINTERPRETED_FN_DEF:
                sequence_UninterpretedFnDef(context, (UninterpretedFnDef) semanticObject);
                return;
            case AgreePackage.WHEN_HOLDS_STATEMENT:
                sequence_WhenStatement(context, (WhenHoldsStatement) semanticObject);
                return;
            case AgreePackage.WHEN_OCCURS_STATMENT:
                sequence_WhenStatement(context, (WhenOccursStatment) semanticObject);
                return;
            case AgreePackage.WHENEVER_BECOMES_TRUE_STATEMENT:
                sequence_WheneverStatement(context, (WheneverBecomesTrueStatement) semanticObject);
                return;
            case AgreePackage.WHENEVER_HOLDS_STATEMENT:
                sequence_WheneverStatement(context, (WheneverHoldsStatement) semanticObject);
                return;
            case AgreePackage.WHENEVER_IMPLIES_STATEMENT:
                sequence_WheneverStatement(context, (WheneverImpliesStatement) semanticObject);
                return;
            case AgreePackage.WHENEVER_OCCURS_STATEMENT:
                sequence_WheneverStatement(context, (WheneverOccursStatement) 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)

Example 60 with StringLiteral

use of org.osate.aadl2.StringLiteral in project AGREE by loonwerks.

the class AgreeValidator method checkAADLEnumerator.

@Check(CheckType.FAST)
public void checkAADLEnumerator(EnumLitExpr aadlEnum) {
    DoubleDotRef enumType = aadlEnum.getEnumType();
    NamedElement enumTypeNamedElement = enumType.getElm();
    // >>>>>>> origin/develop
    if (!AgreeAADLEnumerationUtils.isAADLEnumeration(enumTypeNamedElement)) {
        error(enumType, "AADL Enumerations must refer to a Data Type with \"Enum\" data representation " + "property and have an \"Enumerators\' property value list.");
    } else {
        String enumVal = aadlEnum.getValue();
        List<String> enumerators = AgreeAADLEnumerationUtils.getEnumerators((ComponentClassifier) enumTypeNamedElement).stream().map(pe -> ((org.osate.aadl2.StringLiteral) pe).getValue()).collect(Collectors.toList());
        if (!enumerators.stream().anyMatch(ev -> ev.equalsIgnoreCase(enumVal))) {
            error(aadlEnum, "AADL Enumeration " + enumTypeNamedElement.getQualifiedName() + " does not have an enumeration value " + enumVal);
        }
    }
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) AnnexUtil(org.osate.annexsupport.AnnexUtil) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Map(java.util.Map) OrderStatement(com.rockwellcollins.atc.agree.agree.OrderStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) BigInteger(java.math.BigInteger) Check(org.eclipse.xtext.validation.Check) WheneverOccursStatement(com.rockwellcollins.atc.agree.agree.WheneverOccursStatement) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) SporadicStatement(com.rockwellcollins.atc.agree.agree.SporadicStatement) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) Set(java.util.Set) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) AadlPackage(org.osate.aadl2.AadlPackage) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) ModelUnit(org.osate.aadl2.ModelUnit) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) TimeInterval(com.rockwellcollins.atc.agree.agree.TimeInterval) DataType(org.osate.aadl2.DataType) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) Feature(org.osate.aadl2.Feature) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) CheckType(org.eclipse.xtext.validation.CheckType) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) AgreeAADLEnumerationUtils(com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FeatureGroup(org.osate.aadl2.FeatureGroup) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement) PropertyConstant(org.osate.aadl2.PropertyConstant) EventPort(org.osate.aadl2.EventPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FeatureGroupType(org.osate.aadl2.FeatureGroupType) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) DataPort(org.osate.aadl2.DataPort) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) PeriodicStatement(com.rockwellcollins.atc.agree.agree.PeriodicStatement) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) AnnexSubclause(org.osate.aadl2.AnnexSubclause) NamedElement(org.osate.aadl2.NamedElement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) DataImplementation(org.osate.aadl2.DataImplementation) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeContractLibrary(com.rockwellcollins.atc.agree.agree.AgreeContractLibrary) Port(org.osate.aadl2.Port) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) HashMultimap(com.google.common.collect.HashMultimap) Classifier(org.osate.aadl2.Classifier) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) NodeLemma(com.rockwellcollins.atc.agree.agree.NodeLemma) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) Collectors(java.util.stream.Collectors) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Property(org.osate.aadl2.Property) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) SynchStatement(com.rockwellcollins.atc.agree.agree.SynchStatement) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) WhenHoldsStatement(com.rockwellcollins.atc.agree.agree.WhenHoldsStatement) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) HashMap(java.util.HashMap) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Expr(com.rockwellcollins.atc.agree.agree.Expr) HashSet(java.util.HashSet) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InitialStatement(com.rockwellcollins.atc.agree.agree.InitialStatement) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DirectionType(org.osate.aadl2.DirectionType) WheneverBecomesTrueStatement(com.rockwellcollins.atc.agree.agree.WheneverBecomesTrueStatement) ExprCycleVisitor(com.rockwellcollins.atc.agree.visitors.ExprCycleVisitor) LinkedList(java.util.LinkedList) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) Iterator(java.util.Iterator) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) EventDataPort(org.osate.aadl2.EventDataPort) LinearizationInterval(com.rockwellcollins.atc.agree.agree.LinearizationInterval) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) WheneverImpliesStatement(com.rockwellcollins.atc.agree.agree.WheneverImpliesStatement) WheneverHoldsStatement(com.rockwellcollins.atc.agree.agree.WheneverHoldsStatement) Abstraction(com.rockwellcollins.atc.agree.agree.Abstraction) WhenOccursStatment(com.rockwellcollins.atc.agree.agree.WhenOccursStatment) Collections(java.util.Collections) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

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