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;
}
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;
}
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;
}
Aggregations