Search in sources :

Example 1 with PropertiesLinkingService

use of org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService in project osate2 by osate.

the class AadlBaLegalityRulesChecker method D_3_L5_Check.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Legality rule
 * Section : D.3 Behavior Specification
 * Object : Check legality rule D.3.(L5)
 * Keys : subprogram dispatch condition transition
 */
public boolean D_3_L5_Check(DispatchCondition dc) {
    boolean canBeDispatched = false;
    // Only accept dispatch conditions on components for which a Dispatch_Protocl can be associated
    PackageSection[] contextsTab = AadlBaVisitors.getBaPackageSections(_ba);
    PropertiesLinkingService pls = Aadl2Visitors.getPropertiesLinkingService(contextsTab[0]);
    Property dispatchProtocolProperty = pls.findPropertyDefinition(_baParentContainer, AadlBaVisitors.DISPATCH_PROTOCOL_PROPERTY_NAME);
    if (dispatchProtocolProperty != null) {
        List<MetaclassReference> appliesToMetaClasses = dispatchProtocolProperty.getAppliesToMetaclasses();
        for (MetaclassReference mClass : appliesToMetaClasses) {
            String mMetaClassName = mClass.getMetaclass().getName();
            String CategoryName = _baParentContainer.getCategory().getName();
            if (mMetaClassName.equalsIgnoreCase(CategoryName)) {
                canBeDispatched = true;
                break;
            }
        }
    }
    ComponentCategory cc = _baParentContainer.getCategory();
    if (cc.equals(ComponentCategory.ABSTRACT)) {
        this.reportLegalityWarning(dc, "Using a dispatch condition in an abstract component " + "means this component can only be refined into a component category on which the " + "Dispatch_Protocol property can be applied");
    } else if (canBeDispatched == false) {
        this.reportLegalityError(dc, cc.getName() + " components cannot contain" + " a dispatch condition in any of their transitions: they cannot be dispatched " + "(extension of Behavior Annex D.3.(L5) legality rule)");
        return false;
    }
    return true;
}
Also used : PropertiesLinkingService(org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService) PackageSection(org.osate.aadl2.PackageSection) MetaclassReference(org.osate.aadl2.MetaclassReference) Property(org.osate.aadl2.Property) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 2 with PropertiesLinkingService

use of org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService in project osate2 by osate.

the class Aadl2Visitors method findElementInPropertySet.

/**
 * Find a property in a propertyset based on their name from the given point of
 * view (package section) or return {@code null}.
 *
 * @param elementName the element's name
 * @param propertySetName the propertyset's name
 * @param context the given point of view
 * @return the property or {@code null}
 */
public static NamedElement findElementInPropertySet(String elementName, String propertySetName, PackageSection context) {
    NamedElement result = null;
    PropertiesLinkingService pls = Aadl2Visitors.getPropertiesLinkingService(context);
    // First in the predeclared propertysets.
    // Why this, i don't know ...
    EReference reference = Aadl2Package.eINSTANCE.getNamedValue_NamedValue();
    result = (NamedElement) pls.findNamedElementInPredeclaredPropertySets(elementName, context, reference);
    // Then in the imported property sets.
    if (result == null) {
        PropertySet ps = null;
        ps = pls.findPropertySet(context, propertySetName);
        if (ps != null) {
            result = ps.findNamedElement(elementName);
        }
    }
    return result;
}
Also used : PropertiesLinkingService(org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService) PropertySet(org.osate.aadl2.PropertySet) NamedElement(org.osate.aadl2.NamedElement) EReference(org.eclipse.emf.ecore.EReference)

Example 3 with PropertiesLinkingService

use of org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService in project osate2 by osate.

the class Aadl2Visitors method findElementInPackage.

/**
 * Find an element in a package based on their name from the given point of
 * view (package section) or return {@code null}.
 *
 * @param elementName the element's name
 * @param packageName the package's name
 * @param context the given point of view
 * @return the element or {@code null}
 */
public static NamedElement findElementInPackage(String elementName, String packageName, PackageSection context) {
    NamedElement result = null;
    NamedElement rootContainer = context.getElementRoot();
    String currentNamespace = rootContainer.getName();
    PropertiesLinkingService pls = Aadl2Visitors.getPropertiesLinkingService(context);
    if (packageName == null || currentNamespace == null || currentNamespace.equalsIgnoreCase(packageName)) {
        // The element is declared into the current context.
        result = pls.findNamedElementInsideAadlPackage(elementName, context);
    } else // The element is defined into an imported package.
    {
        result = pls.findNamedElementInAadlPackage(packageName, elementName, context);
    }
    return result;
}
Also used : PropertiesLinkingService(org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

PropertiesLinkingService (org.osate.xtext.aadl2.properties.linking.PropertiesLinkingService)3 NamedElement (org.osate.aadl2.NamedElement)2 EReference (org.eclipse.emf.ecore.EReference)1 ComponentCategory (org.osate.aadl2.ComponentCategory)1 MetaclassReference (org.osate.aadl2.MetaclassReference)1 PackageSection (org.osate.aadl2.PackageSection)1 Property (org.osate.aadl2.Property)1 PropertySet (org.osate.aadl2.PropertySet)1