Search in sources :

Example 1 with DeclarativeBehaviorElement

use of org.osate.ba.declarative.DeclarativeBehaviorElement in project osate2 by osate.

the class AadlBaTypeChecker method getType.

/**
 * Returns the feature type of the element binded to the given behavior
 * annex element.
 *
 * @param el the given behavior annex element
 * @return the feature type of the binded element
 */
static Enum<?> getType(DeclarativeBehaviorElement el) {
    org.osate.aadl2.Element testedEl = AadlBaTypeChecker.getBindedElement(el);
    Enum<?> result;
    if (testedEl instanceof BehaviorElement) {
        result = AadlBaUtils.getBehaviorAnnexFeatureType((BehaviorElement) testedEl);
    } else {
        result = AadlBaUtils.getFeatureType(testedEl);
    }
    return result;
}
Also used : Element(org.osate.aadl2.Element) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement)

Example 2 with DeclarativeBehaviorElement

use of org.osate.ba.declarative.DeclarativeBehaviorElement in project osate2 by osate.

the class AadlBaNameResolver method classifierFeaturePropertyReferenceResolver.

private boolean classifierFeaturePropertyReferenceResolver(DeclarativePropertyReference ref) {
    Reference component = ref.getReference();
    if (refResolver(component)) {
        PropertyAssociation pa = null;
        Classifier type = null;
        Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
        Element el = (component.getOsateRef() != null) ? component.getOsateRef() : component.getBaRef();
        if (el instanceof PrototypeBinding) {
            PrototypeBinding pb = (PrototypeBinding) el;
            type = AadlBaUtils.getClassifier(pb, pb.getContainingClassifier());
        } else if (el instanceof ClassifierFeature) {
            ClassifierFeature cf = (ClassifierFeature) el;
            // Fetch the own property association of the classifier feature.
            pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), cf);
            if (pa == null) {
                type = AadlBaUtils.getClassifier(cf, cf.getContainingClassifier());
            }
        } else if (el instanceof BehaviorVariable) {
            BehaviorVariable bv = (BehaviorVariable) el;
            DeclarativeBehaviorElement de = (DeclarativeBehaviorElement) bv.getDataClassifier();
            if (de.getOsateRef() instanceof Classifier) {
                type = (Classifier) de.getOsateRef();
            }
        } else // Cannot resolve or unimplemented cases.
        {
            String msg = "the type of \'" + ((NamedElement) el).getName() + "\' cannot be resolved";
            _errManager.error(el, msg);
        }
        // search within its type.
        if (pa == null && type != null) {
            pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), type);
        }
        if (pa != null) {
            ref.getPropertyNames().get(0).setOsateRef(pa);
            propertyNameId.setOsateRef(pa);
            return propertyNameResolver(ref.getPropertyNames());
        } else {
            reportNameError(propertyNameId, propertyNameId.getId());
            return false;
        }
    } else {
        // refResolver has already reported the error.
        return false;
    }
}
Also used : DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) Reference(org.osate.ba.declarative.Reference) PropertyAssociation(org.osate.aadl2.PropertyAssociation) DeclarativeBasicPropertyAssociation(org.osate.ba.declarative.DeclarativeBasicPropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) PrototypeBinding(org.osate.aadl2.PrototypeBinding) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ClassifierFeature(org.osate.aadl2.ClassifierFeature)

Example 3 with DeclarativeBehaviorElement

use of org.osate.ba.declarative.DeclarativeBehaviorElement in project osate2 by osate.

the class AadlBaTypeChecker method typeCheck.

/**
 * Checks the type of the reference binded to the given declarative behavior
 * element within the given rule's expected types. Returns the
 * matching feature type or {@code null} otherwise. Reports any error if
 * hasToReport is {@code true}.
 *
 * @param dbe the declarative behavior element to be checked
 * @param name the behavior element's name
 * @param rule the checking rule that contains the expected types
 * @param hasToReport flag for report error
 * @return the matching feature type or {@code null}
 */
private Enum<?> typeCheck(DeclarativeBehaviorElement dbe, String name, TypeCheckRule rule, boolean hasToReport) {
    Enum<?> result = rule.test(dbe, _baParentContainer);
    if (result == null && hasToReport) {
        Enum<?> testedEnum = AadlBaTypeChecker.getType(dbe);
        // Resolves feature prototype binding.
        if (testedEnum == FeatureType.FEATURE_PROTOTYPE_BINDING) {
            Element el = AadlBaTypeChecker.getBindedElement(dbe);
            testedEnum = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) el);
        }
        String expectedTypes = rule.getExpectedTypes(STRING_TYPE_SEPARATOR);
        String typeFound = ((Enumerator) testedEnum).getLiteral();
        reportTypeError(dbe, name, expectedTypes, typeFound);
    }
    return result;
}
Also used : Enumerator(org.eclipse.emf.common.util.Enumerator) Element(org.osate.aadl2.Element) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding)

Aggregations

Element (org.osate.aadl2.Element)3 DeclarativeBehaviorElement (org.osate.ba.declarative.DeclarativeBehaviorElement)3 NamedElement (org.osate.aadl2.NamedElement)2 QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)2 Enumerator (org.eclipse.emf.common.util.Enumerator)1 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)1 Classifier (org.osate.aadl2.Classifier)1 ClassifierFeature (org.osate.aadl2.ClassifierFeature)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)1 DataClassifier (org.osate.aadl2.DataClassifier)1 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)1 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)1 PropertyAssociation (org.osate.aadl2.PropertyAssociation)1 PrototypeBinding (org.osate.aadl2.PrototypeBinding)1 BehaviorElement (org.osate.ba.aadlba.BehaviorElement)1 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)1 ArrayableIdentifier (org.osate.ba.declarative.ArrayableIdentifier)1 DeclarativeBasicPropertyAssociation (org.osate.ba.declarative.DeclarativeBasicPropertyAssociation)1 DeclarativePropertyReference (org.osate.ba.declarative.DeclarativePropertyReference)1