Search in sources :

Example 46 with ContainmentPathElement

use of org.osate.aadl2.ContainmentPathElement 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 47 with ContainmentPathElement

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

the class ResolvePrototypeUtil method resolvePrototype.

/**
 * Find the binding for a given prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context of the entity in which the prototype is used, e.g., a
 *            ComponentType, ComponentImplementation, FeatureGroupType, Subcomponent
 * @return The binding that assigns the value to the prototype relative to
 *         its usage context.
 */
public static PrototypeBinding resolvePrototype(Prototype proto, Element context) {
    PrototypeBinding result = null;
    if (context instanceof Classifier) {
        Classifier impl = (Classifier) context;
        result = impl.lookupPrototypeBinding(proto);
    } else if (context instanceof Subcomponent) {
        Subcomponent parentSub = (Subcomponent) context;
        result = parentSub.lookupPrototypeBinding(proto);
        if (result == null) {
            result = resolvePrototype(proto, parentSub.getAllClassifier());
        }
    } else if (context instanceof ContainmentPathElement) {
        result = resolvePrototypeInContainmentPath(proto, (ContainmentPathElement) context);
    } else if (context instanceof FeatureGroupPrototypeActual) {
        final FeatureGroupPrototypeActual fgpa = (FeatureGroupPrototypeActual) context;
        for (final PrototypeBinding binding : fgpa.getBindings()) {
            if (binding.getFormal() == proto) {
                result = binding;
                break;
            }
        }
    }
    // }
    return result;
}
Also used : Subcomponent(org.osate.aadl2.Subcomponent) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding)

Example 48 with ContainmentPathElement

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

the class ResolvePrototypeUtil method resolveFeatureGroupPrototype.

/**
 * Find the binding for a given feature group prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context of the feature group in which the prototype is used, e.g., a
 *            ComponentType, FeatureGroupType, ContainmentPathElement
 * @return The feature group prototype actual the prototype is bound to.
 */
public static FeatureGroupType resolveFeatureGroupPrototype(FeatureGroupPrototype proto, Element context) {
    FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) resolvePrototype(proto, context);
    if (fgpb == null) {
        // look for constraining classifier
        FeatureGroupPrototype refinedPrototype = proto;
        while (refinedPrototype.getConstrainingFeatureGroupType() != null && refinedPrototype.getRefined() instanceof FeatureGroupPrototype) {
            refinedPrototype = (FeatureGroupPrototype) refinedPrototype.getRefined();
        }
        if (refinedPrototype.getConstrainingFeatureGroupType() != null) {
            return refinedPrototype.getConstrainingFeatureGroupType();
        } else {
            return null;
        }
    }
    FeatureGroupPrototypeActual actual = fgpb.getActual();
    if (actual.getFeatureType() instanceof FeatureGroupType) {
        return (FeatureGroupType) actual.getFeatureType();
    } else {
        if (actual.getFeatureType() instanceof Prototype && context instanceof ContainmentPathElement) {
            // resolve recursively if we are in a containment path
            return resolveFeatureGroupPrototype((FeatureGroupPrototype) actual.getFeatureType(), getPrevious((ContainmentPathElement) context));
        }
    }
    return null;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual)

Example 49 with ContainmentPathElement

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

the class ComponentInstanceImpl method findInstanceObjectsHelper.

/*
	 * (non-Javadoc)
	 *
	 * @see org.osate.aadl2.instance.impl.InstanceObjectImpl#findInstanceObjectsHelper(java.util.ListIterator, java.util.List)
	 */
protected boolean findInstanceObjectsHelper(ListIterator<ContainmentPathElement> pathIter, List<InstanceObject> ios) {
    boolean result = super.findInstanceObjectsHelper(pathIter, ios);
    if (!result && pathIter.hasNext()) {
        // add connections
        ContainmentPathElement cpe = pathIter.next();
        NamedElement ne = cpe.getNamedElement();
        if (ne instanceof Connection) {
            ios.addAll(findConnectionInstance((Connection) ne));
        }
        pathIter.previous();
    }
    return result;
}
Also used : ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Connection(org.osate.aadl2.Connection) NamedElement(org.osate.aadl2.NamedElement)

Example 50 with ContainmentPathElement

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

the class PropertiesValidator method checkPropertyReferenceAppliesTo.

@Check
public void checkPropertyReferenceAppliesTo(NamedValue namedValue) {
    AbstractNamedValue anv = namedValue.getNamedValue();
    PropertyAssociation association = EcoreUtil2.getContainerOfType(namedValue, PropertyAssociation.class);
    if (!anv.eIsProxy() && anv instanceof Property && association != null) {
        Property referencedProperty = (Property) anv;
        List<ContainedNamedElement> appliesTo = association.getAppliesTos();
        if (appliesTo.isEmpty()) {
            NamedElement holder = EcoreUtil2.getContainerOfType(association, NamedElement.class);
            if (holder != null && !holder.acceptsProperty(referencedProperty)) {
                error("Property " + referencedProperty.getQualifiedName() + " does not apply to " + holder.getName());
            }
        } else {
            for (ContainedNamedElement cna : appliesTo) {
                List<ContainmentPathElement> path = cna.getContainmentPathElements();
                if (!path.isEmpty()) {
                    NamedElement holder = path.get(path.size() - 1).getNamedElement();
                    if (!holder.eIsProxy() && !holder.acceptsProperty(referencedProperty)) {
                        error("Property " + referencedProperty.getQualifiedName() + " does not apply to " + unparseAppliesTo(cna));
                    }
                }
            }
        }
    }
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Aggregations

ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)52 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)27 NamedElement (org.osate.aadl2.NamedElement)24 PropertyAssociation (org.osate.aadl2.PropertyAssociation)19 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)15 ReferenceValue (org.osate.aadl2.ReferenceValue)14 Property (org.osate.aadl2.Property)12 Subcomponent (org.osate.aadl2.Subcomponent)12 IntegerLiteral (org.osate.aadl2.IntegerLiteral)11 ListValue (org.osate.aadl2.ListValue)11 NamedValue (org.osate.aadl2.NamedValue)11 ArrayRange (org.osate.aadl2.ArrayRange)10 RangeValue (org.osate.aadl2.RangeValue)10 RealLiteral (org.osate.aadl2.RealLiteral)10 RecordValue (org.osate.aadl2.RecordValue)10 BooleanLiteral (org.osate.aadl2.BooleanLiteral)9 ClassifierValue (org.osate.aadl2.ClassifierValue)9 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)9 StringLiteral (org.osate.aadl2.StringLiteral)9 EObject (org.eclipse.emf.ecore.EObject)7