use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.
the class AadlBaNameResolver method resolveProperty.
private Property resolveProperty(QualifiedNamedElement qne) {
String packageName = "";
boolean hasNamespace = qne.getBaNamespace() != null;
if (hasNamespace) {
packageName = qne.getBaNamespace().getId();
}
NamedElement propNE = Aadl2Visitors.findElementInPropertySet(qne.getBaName().getId(), packageName, Aadl2Visitors.getContainingPackageSection(_ba));
return (Property) propNE;
}
use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.
the class AadlBaNameResolver method qualifiedNamedElementResolver.
private boolean qualifiedNamedElementResolver(QualifiedNamedElement qne, boolean hasToReport) {
String packageName = null;
EObject ne;
boolean hasNamespace = qne.getBaNamespace() != null;
if (hasNamespace) {
packageName = qne.getBaNamespace().getId();
}
// Now check the type in each current package's sections.
for (PackageSection context : _contextsTab) {
NamedElement parent = (NamedElement) _ba.eContainer().eContainer();
ne = Aadl2Visitors.findSubcomponentInComponent((Classifier) parent, qne.getBaName().getId());
if (ne == null) {
ne = Aadl2Visitors.findFeatureInComponent((Classifier) parent, qne.getBaName().getId());
}
if (ne == null) {
ne = Aadl2Visitors.findElementInPackage(qne.getBaName().getId(), packageName, context);
}
if (ne == null) {
ne = Aadl2Visitors.findElementInPropertySet(qne.getBaName().getId(), packageName, context);
}
// An element is found.
if (ne != null && ne instanceof NamedElement) {
// Links unique component classifier reference with named element found.
qne.setOsateRef((Element) ne);
qne.getBaName().setOsateRef((Element) ne);
if (hasNamespace) {
qne.getBaNamespace().setOsateRef(((NamedElement) ne).getNamespace());
}
return true;
}
}
// The element is not found.
if (hasToReport) {
StringBuilder qualifiedName = new StringBuilder();
if (hasNamespace) {
qualifiedName.append(qne.getBaNamespace().getId());
qualifiedName.append("::");
}
qualifiedName.append(qne.getBaName().getId());
reportNameError(qne, qualifiedName.toString());
}
return false;
}
use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.
the class AadlBaNameResolver method behaviorActionResolver.
private boolean behaviorActionResolver(BehaviorAction act) {
boolean result = true;
// Case of basic action.
if (act instanceof BasicAction) {
result = basicActionResolver((BasicAction) act);
} else {
if (act instanceof BehaviorActionBlock) {
result = behaviorActionBlockResolver((BehaviorActionBlock) act);
} else {
// Case of IF statement.
if (act instanceof IfStatement) {
result = ifStatementResolver((IfStatement) act);
} else {
// Case if WHILE and DO UNTIL statement.
if (act instanceof WhileOrDoUntilStatement) {
WhileOrDoUntilStatement stat = (WhileOrDoUntilStatement) act;
result = valueExpressionResolver(stat.getLogicalValueExpression());
result &= behaviorActionsResolver(stat.getBehaviorActions());
} else // Case of FOR and FOR ALL statement.
{
ForOrForAllStatement stat = (ForOrForAllStatement) act;
IterativeVariable itVar = stat.getIterativeVariable();
// Resolves unique component classifier reference.
QualifiedNamedElement uccr = (QualifiedNamedElement) itVar.getDataClassifier();
result = qualifiedNamedElementResolver(uccr, true);
// Checks the for/forall's iterative variable.
result &= iterativeVariableUniquenessCheck(itVar);
// Add the for/forall statment's iterative variable to
// the scope handler.
_itvScope.add(itVar);
// Check element values.
result &= elementValuesResolver(stat.getIteratedValues());
// Check behavior actions.
result &= behaviorActionsResolver(stat.getBehaviorActions());
// remove the for/forall statment's iterative variable from
// the scope handler (after checking for/forall's behavior
// actions.
_itvScope.remove(itVar);
}
}
// End of third else.
}
// End of second else.
}
return result;
}
use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.
the class AadlBaTypeChecker method behaviorVariableCheck.
/**
* Document: AADL Behavior Annex draft
* Version : 0.94
* Type : Semantic rule
* Section : D.3 Behavior Specification
* Object : Check semantic rule D.3.(28)
* Keys : local variables explicitly typed valid data component classifier
*/
private boolean behaviorVariableCheck() {
boolean result = true;
IntegerValueConstant ivc = null;
QualifiedNamedElement uccr;
for (BehaviorVariable bv : _ba.getVariables()) {
uccr = (QualifiedNamedElement) bv.getDataClassifier();
DataClassifier dc = (DataClassifier) uniqueNamedElementReferenceResolver(uccr, TypeCheckRule.DATA_UCCR);
_hl.addToHyperlinking(uccr.getAadlBaLocationReference(), dc);
result &= dc != null;
bv.setDataClassifier(dc);
for (PropertyAssociation pa : bv.getOwnedPropertyAssociations()) {
Property p = (Property) uniqueNamedElementReferenceResolver((QualifiedNamedElement) pa.getProperty(), TypeCheckRule.PROPERTY);
pa.setProperty(p);
}
ListIterator<ArrayDimension> it = bv.getArrayDimensions().listIterator();
while (it.hasNext()) {
ArrayDimension tmp = it.next();
DeclarativeArrayDimension dad = (DeclarativeArrayDimension) tmp;
ivc = dad.getDimension();
ivc = integerValueConstantCheck(ivc);
result &= ivc != null;
// integervalueConstantCheck method. So replace if needed.
if (ivc != null) {
it.set(integerValueConstantToArrayDimension(ivc));
}
}
}
return result;
}
use of org.osate.ba.declarative.QualifiedNamedElement in project osate2 by osate.
the class AadlBaTypeChecker method portDequeueActionResolver.
private PortDequeueAction portDequeueActionResolver(CommAction comAct) {
// if already resolved, check port ref is event or event data port
QualifiedNamedElement qne = comAct.getQualifiedName();
if (qne != null) {
boolean isOfExpectedType = qne.getOsateRef() instanceof EventPort || qne.getOsateRef() instanceof EventDataPort;
if (!isOfExpectedType) {
String name = "referenced object";
if (qne.getOsateRef() instanceof NamedElement) {
NamedElement ne = (NamedElement) qne.getOsateRef();
name = ne.getName();
} else if (qne.getBaRef() instanceof BehaviorNamedElement) {
BehaviorNamedElement bne = (BehaviorNamedElement) qne.getBaRef();
name = bne.getName();
} else if (qne.getBaName().getId() != null) {
name = qne.getBaName().getId();
} else if (qne.getName() != null) {
name = qne.getName();
}
reportError(comAct, "incorrect port dequeue action, " + name + " is not an event [data] port");
return null;
}
} else if (comAct.getReference() == null) {
return null;
}
Target tarTmp = null;
boolean tarCheckResult = true;
TypeCheckRule stopOnThisRule = TypeCheckRule.IN_PORT;
TypeCheckRule checkRule = TypeCheckRule.PORT_DEQUEUE_VALUE;
List<ElementHolder> resolvedRef = refResolver(comAct.getReference(), null, stopOnThisRule, checkRule);
if (resolvedRef != null) {
PortHolder portHolder = (PortHolder) resolvedRef.get(0);
return portDequeueActionResolver(portHolder, comAct);
} else {
return null;
}
}
Aggregations