use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeScopeProvider 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 AGREE by loonwerks.
the class RecordLitExprImpl method basicSetRecordType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetRecordType(DoubleDotRef newRecordType, NotificationChain msgs) {
DoubleDotRef oldRecordType = recordType;
recordType = newRecordType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.RECORD_LIT_EXPR__RECORD_TYPE, oldRecordType, newRecordType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkNodeStmt.
@Check(CheckType.FAST)
public void checkNodeStmt(NodeStmt nodeStmt) {
List<NamedElmExpr> dotIds = EcoreUtil2.getAllContentsOfType(nodeStmt, NamedElmExpr.class);
for (NamedElmExpr dotId : dotIds) {
NamedElement id = dotId.getElm();
// restrict the elements that are single names or the last projection.
boolean restrictedElm = true;
if (dotId.eContainer() instanceof SelectionExpr) {
NamedElement ne = ((SelectionExpr) dotId.eContainer()).getField();
restrictedElm = ne == id && !(dotId.eContainer().eContainer() instanceof SelectionExpr);
}
if (restrictedElm && !(id instanceof Arg) && !(id instanceof ConstStatement) && !(id instanceof NodeDef) && !(id instanceof FnDef) && !(id instanceof UninterpretedFnDef) && !(id instanceof DataSubcomponent) && !(id instanceof DoubleDotRef) && !(id instanceof DataImplementation) && !(id instanceof RecordDef) && !(id instanceof NamedID)) {
error(dotId, "Only arguments, constants, and node calls allowed within a node");
}
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkAADLEnumerator.
@Check(CheckType.FAST)
public void checkAADLEnumerator(EnumLitExpr aadlEnum) {
DoubleDotRef enumType = aadlEnum.getEnumType();
NamedElement enumTypeNamedElement = enumType.getElm();
// >>>>>>> origin/develop
if (!AgreeAADLEnumerationUtils.isAADLEnumeration(enumTypeNamedElement)) {
error(enumType, "AADL Enumerations must refer to a Data Type with \"Enum\" data representation " + "property and have an \"Enumerators\' property value list.");
} else {
String enumVal = aadlEnum.getValue();
List<String> enumerators = AgreeAADLEnumerationUtils.getEnumerators((ComponentClassifier) enumTypeNamedElement).stream().map(pe -> ((org.osate.aadl2.StringLiteral) pe).getValue()).collect(Collectors.toList());
if (!enumerators.stream().anyMatch(ev -> ev.equalsIgnoreCase(enumVal))) {
error(aadlEnum, "AADL Enumeration " + enumTypeNamedElement.getQualifiedName() + " does not have an enumeration value " + enumVal);
}
}
}
use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.
the class AgreeValidator method checkInputsVsActuals.
public void checkInputsVsActuals(CallExpr call) {
DoubleDotRef dotId = call.getRef();
NamedElement namedEl = dotId.getElm();
if (!(namedEl instanceof Abstraction)) {
// this error will be caught elsewhere
return;
}
Abstraction callDef = (Abstraction) namedEl;
List<TypeDef> inDefTypes;
String callName;
// extract in/out arguments
if (callDef instanceof FnDef) {
FnDef fnDef = (FnDef) callDef;
inDefTypes = typeDefsFromArgs(fnDef.getArgs());
callName = fnDef.getName();
} else if (callDef instanceof NodeDef) {
NodeDef nodeDef = (NodeDef) callDef;
inDefTypes = typeDefsFromArgs(nodeDef.getArgs());
callName = nodeDef.getName();
} else if (callDef instanceof LinearizationDef) {
LinearizationDef linDef = (LinearizationDef) callDef;
inDefTypes = typeDefsFromArgs(linDef.getArgs());
callName = linDef.getName();
} else if (callDef instanceof LibraryFnDef) {
LibraryFnDef nativeDef = (LibraryFnDef) callDef;
inDefTypes = typeDefsFromArgs(nativeDef.getArgs());
callName = nativeDef.getName();
} else if (callDef instanceof UninterpretedFnDef) {
UninterpretedFnDef nativeDef = (UninterpretedFnDef) callDef;
inDefTypes = typeDefsFromArgs(nativeDef.getArgs());
callName = nativeDef.getName();
} else {
error(call, "Node, function or linearization definition name expected.");
return;
}
// extract args
List<TypeDef> argCallTypes = new ArrayList<>();
for (Expr expr : call.getArgs()) {
checkTypeExists(expr);
argCallTypes.add(AgreeTypeSystem.infer(expr));
}
if (inDefTypes.size() != argCallTypes.size()) {
error(call, "Function definition '" + callName + "' requires " + inDefTypes.size() + " arguments, but this function call provides " + argCallTypes.size() + " arguments");
return;
}
for (int i = 0; i < inDefTypes.size(); i++) {
TypeDef callType = argCallTypes.get(i);
TypeDef defType = inDefTypes.get(i);
if (!AgreeTypeSystem.typesEqual(defType, callType)) {
error(call, "Argument " + i + " of function call '" + callName + "' is of type '" + callType + "' but must be of type '" + defType + "'");
}
}
}
Aggregations