use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class SafetyValidator method checkFaultSpecStmt.
/**
* Checks description string, warning if empty, and checks that the
* fault node name is valid.
* @param specStmt
*/
@Check(CheckType.FAST)
public void checkFaultSpecStmt(FaultStatement specStmt) {
DoubleDotRef nodeName = specStmt.getFaultDefName();
// Check on fault description
if (specStmt.getStr().isEmpty()) {
warning(specStmt, "Fault description is optional, but should " + "not be an empty string.");
}
// Check that the NamedElement (fault node name) is a valid node definition
NamedElement finalNodeName = nodeName.getElm();
if (!(finalNodeName instanceof NodeDef)) {
error(nodeName, "The fault name must be a valid node definition.");
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class SafetyValidator method checkInput.
/**
* Checks fault def name is valid,
* expressions passed into node match parameter types,
* and correct number of arguments passed in.
*
* @param inputs
*/
@Check(CheckType.FAST)
public void checkInput(InputStatement inputs) {
EObject container = inputs.eContainer();
NamedElement defNameSub;
List<Expr> exprList = inputs.getNom_conn();
List<String> inputList = inputs.getFault_in();
ArrayList<String> argNames = new ArrayList<String>();
if (container instanceof FaultStatement) {
FaultStatement faultStatement = (FaultStatement) container;
DoubleDotRef defName = faultStatement.getFaultDefName();
defNameSub = defName.getElm();
// Make sure we have a NodeDefExpr
if (defNameSub instanceof NodeDef) {
List<Arg> nodeArgs = ((NodeDef) defNameSub).getArgs();
for (Arg arg : nodeArgs) {
argNames.add(arg.getFullName());
if (arg.getType() instanceof DoubleDotRefImpl) {
if ((((DoubleDotRefImpl) arg.getType()).getElm() instanceof PropertyImpl) || (((DoubleDotRefImpl) arg.getType()).getElm() instanceof DataTypeImpl)) {
error(inputs, "Fault node parameters are not recognized: a possible issue is that the keyword 'float' is used instead of 'real.'");
}
}
}
// If the sizes are accurate, make sure names match
if (nodeArgs.size() - 1 == (inputList.size())) {
// Go through input list and make sure each name is in the arg list
for (String inputName : inputList) {
if (!argNames.contains(inputName)) {
error(inputs, "Input names must match fault node definition names. " + "The input name " + inputName + " is not an input in the node definition. " + "All possible input names are: " + argNames.toString());
}
}
} else {
argNames.remove("trigger");
error(inputs, "With this fault definition, you must have " + (argNames.size() - 1) + " inputs." + " These are called: " + argNames.toString());
}
if (inputListHasRepeats(inputList)) {
error(inputs, "There is a repeated name in the input list: " + inputList.toString());
}
if (!checkInputTypes(exprList, nodeArgs)) {
error(inputs, "Types of inputs do not match types of node parameters");
}
} else {
// Not a node def expr
error(defName, "Fault definition: " + defNameSub.getFullName() + " must be a valid agree node definition name.");
}
} else {
error(inputs, "Fault inputs must be defined within a fault statement.");
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class FaultStatementImpl method basicSetFaultDefName.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFaultDefName(DoubleDotRef newFaultDefName, NotificationChain msgs) {
DoubleDotRef oldFaultDefName = faultDefName;
faultDefName = newFaultDefName;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.FAULT_STATEMENT__FAULT_DEF_NAME, oldFaultDefName, newFaultDefName);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class SafetyScopeProvider method scope_GetPropertyExpr_prop.
protected IScope scope_GetPropertyExpr_prop(GetPropertyExpr ctx, EReference ref) {
IScope prevScope = prevScope(ctx, ref);
ComponentRef cr = ctx.getComponentRef();
if (cr instanceof ThisRef) {
List<Property> ps = new ArrayList<>();
EObject container = ctx.getContainingClassifier();
while (container != null) {
if (container instanceof Classifier) {
List<PropertyAssociation> pas = ((Classifier) container).getAllPropertyAssociations();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
container = ((Classifier) container).eContainer();
} else if (container instanceof AadlPackage) {
for (PropertySet propSet : EcoreUtil2.getAllContentsOfType(container, PropertySet.class)) {
for (Property p : propSet.getOwnedProperties()) {
ps.add(p);
}
// =======
// EList<EObject> refs = null;
//
// if (container instanceof NestedDotID) {
// NestedDotID parent = (NestedDotID) container;
// refs = parent.eCrossReferences();
//
// if (refs.size() != 1) {
// return new HashSet<>(); // this will throw a parsing error
// }
// container = refs.get(0); // figure out what this type this portion
//
// // of the nest id is so we can figure out
// // what we could possibly link to
//
// if (container instanceof ThreadSubcomponent) {
// container = ((ThreadSubcomponent) container).getComponentType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Subcomponent) {
// container = ((Subcomponent) container).getComponentImplementation();
// if (container == null) { // no implementation is provided
// container = refs.get(0);
// container = ((Subcomponent) container).getClassifier();
// }
// result.addAll(getAadlElements(container));
// } else if (container instanceof DataPort) {
// container = ((DataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof EventDataPort) {
// container = ((EventDataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof AadlPackage) {
// result.addAll(getAadlElements(container));
// } else if (container instanceof FeatureGroupImpl) {
// container = ((FeatureGroupImpl) container).getAllFeatureGroupType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Arg || container instanceof ConstStatement) {
// Type type;
//
// if (container instanceof Arg) {
// type = ((Arg) container).getType();
// } else {
// type = ((ConstStatement) container).getType();
// }
//
// if (type instanceof RecordType) {
// DoubleDotRef elID = ((RecordType) type).getRecord();
// NamedElement namedEl = elID.getElm();
//
// if (namedEl instanceof ComponentImplementation) {
// ComponentImplementation componentImplementation = (ComponentImplementation) namedEl;
// EList<Subcomponent> subs = componentImplementation.getAllSubcomponents();
// result.addAll(subs);
// } else if (namedEl instanceof RecordDefExpr) {
// result.addAll(((RecordDefExpr) namedEl).getArgs());
// >>>>>>> origin/develop
}
container = null;
} else {
container = container.eContainer();
}
}
return Scopes.scopeFor(ps, prevScope);
} else if (cr instanceof DoubleDotRef) {
NamedElement ne = ((DoubleDotRef) cr).getElm();
if (ne instanceof Subcomponent) {
List<PropertyAssociation> pas = ((Subcomponent) ne).getOwnedPropertyAssociations();
List<Property> ps = new ArrayList<>();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
return Scopes.scopeFor(ps, prevScope);
}
}
return IScope.NULLSCOPE;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AMASE by loonwerks.
the class SafetyAnnexContentAssist method getNestedDotIDCandidates.
private List<String> getNestedDotIDCandidates(SelectionExpr id) {
NamedElement base = ((NamedElmExpr) id).getElm();
NamedElement namedEl = null;
if (base instanceof Arg) {
Type type = ((Arg) base).getType();
DoubleDotRef elID = ((DoubleDotRef) type);
namedEl = elID.getElm();
} else if (base instanceof DataPort) {
namedEl = ((DataPort) base).getDataFeatureClassifier();
} else if (base instanceof EventDataPort) {
namedEl = ((EventDataPort) base).getDataFeatureClassifier();
} else if (base instanceof AadlPackage) {
return getNestedDotIDCandidates((AadlPackage) base);
} else {
return new ArrayList<>();
}
return getNestedDotIDCandidates(namedEl);
}
Aggregations