use of org.osate.ba.aadlba.IterativeVariable in project osate2 by osate.
the class AadlBaParserVisitor method visitFor_condition.
/**
* {@inheritDoc}
* <p/>
* The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.
*/
@Override
public T visitFor_condition(@NotNull AadlBaParser.For_conditionContext ctx) {
visitChildren(ctx);
ctx.result = _baFact.createForOrForAllStatement();
ctx.result.setForAll(false);
setLocationReference(ctx.result, ctx.FOR());
IterativeVariable itVar = _baFact.createIterativeVariable();
itVar.setName(ctx.IDENT().getText());
setLocationReference(itVar, ctx.IDENT());
ctx.result.setIterativeVariable(itVar);
_dba.getDeclarativeBehaviorElements().add(ctx.unique_component_classifier_reference().result);
itVar.setDataClassifier(ctx.unique_component_classifier_reference().result);
ctx.result.setIteratedValues(ctx.element_values().result);
return null;
}
use of org.osate.ba.aadlba.IterativeVariable in project osate2 by osate.
the class AadlBaUtils method getBehaviorAnnexFeatureType.
/**
* Analyze the given behavior annex feature and returns its type.
*
* @param el the given behavior annex feature
* @return the given behavior annex feature's type
* @exception UnsupportedOperationException for the unsupported types
*/
public static BehaviorFeatureType getBehaviorAnnexFeatureType(BehaviorElement el) {
if (el instanceof org.osate.ba.aadlba.BehaviorVariable) {
return BehaviorFeatureType.BEHAVIOR_VARIABLE;
} else if (el instanceof IterativeVariable) {
return BehaviorFeatureType.ITERATIVE_VARIABLE;
}
String errorMsg = "feature : " + el.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
use of org.osate.ba.aadlba.IterativeVariable in project osate2 by osate.
the class AadlBaNameResolver method refResolver.
// Resolves Reference objects (arrayable identifiers)
// within parent component's features ones and ba's variables ones and
// for/forall's iterative variable scope handler.
private boolean refResolver(Classifier parentContainer, Reference ref) {
boolean result = true;
boolean currentIdResult = false;
ListIterator<ArrayableIdentifier> it = ref.getIds().listIterator();
// Checks ArrayableIdentifier objects.
while (it.hasNext()) {
ArrayableIdentifier id = it.next();
// Can't resolve within a null parent classifier.
if (parentContainer == null) {
result = false;
reportNameError(id, id.getId());
break;
}
if (parentContainer == _baParentContainer) {
currentIdResult = identifierBaResolver(id, false);
}
if (!currentIdResult) {
currentIdResult = identifierComponentResolver(id, parentContainer, true);
}
if (id.isSetArrayIndexes()) {
// Checks array indexes names.
for (IntegerValue index : id.getArrayIndexes()) {
// Recursive call.
result &= integerValueResolver(index);
}
}
// If the current id is found, fetch the container for the next id.
if (currentIdResult && it.hasNext()) {
Element el = AadlBaTypeChecker.getBindedElement(id);
// not been type checked already.
if (el instanceof BehaviorVariable) {
QualifiedNamedElement qne = (QualifiedNamedElement) ((BehaviorVariable) el).getDataClassifier();
parentContainer = (Classifier) qne.getOsateRef();
} else if (el instanceof IterativeVariable) {
IterativeVariable itv = (IterativeVariable) el;
QualifiedNamedElement qne = (QualifiedNamedElement) itv.getDataClassifier();
parentContainer = (Classifier) qne.getOsateRef();
} else {
parentContainer = AadlBaUtils.getClassifier(el, parentContainer);
}
}
// Add the current id result to the global result.
result &= currentIdResult;
// Reset.
currentIdResult = false;
// Don't continue if the current id is not found.
if (result == false) {
break;
}
}
// Binds with the last id reference.
ArrayableIdentifier lastId = ref.getIds().get((ref.getIds().size() - 1));
ref.setOsateRef(lastId.getOsateRef());
ref.setBaRef(lastId.getBaRef());
return result;
}
use of org.osate.ba.aadlba.IterativeVariable in project osate2 by osate.
the class ForOrForAllStatementImpl method basicSetIterativeVariable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIterativeVariable(IterativeVariable newIterativeVariable, NotificationChain msgs) {
IterativeVariable oldIterativeVariable = iterativeVariable;
iterativeVariable = newIterativeVariable;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AadlBaPackage.FOR_OR_FOR_ALL_STATEMENT__ITERATIVE_VARIABLE, oldIterativeVariable, newIterativeVariable);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations