use of com.rockwellcollins.atc.agree.agree.NamedID in project AGREE by loonwerks.
the class AgreeValidator method checkEnumStatement.
@Check(CheckType.FAST)
public void checkEnumStatement(EnumStatement statement) {
String contextProject = statement.eResource().getURI().segment(1);
Map<String, NamedID> enumMap;
if (!enumSets.containsKey(contextProject)) {
enumMap = new HashMap<>();
enumSets.put(contextProject, enumMap);
} else {
enumMap = enumSets.get(contextProject);
}
for (NamedID id : statement.getEnums()) {
NamedID otherEnum = enumMap.get(id.getName());
if (otherEnum == null) {
enumMap.put(id.getName(), id);
} else if (otherEnum != id) {
if (otherEnum.eResource() != null && otherEnum.eResource().equals(id.eResource())) {
String message = "Multiple uses of the same enum value '" + id.getName() + "' in '" + getEnumValueDefLocation(otherEnum) + "' and '" + getEnumValueDefLocation(id) + "'";
error(otherEnum, message);
error(id, message);
} else {
enumMap.put(id.getName(), id);
}
}
}
EObject container = statement.eContainer();
while (!(container instanceof AadlPackage) && !(container instanceof ComponentClassifier)) {
container = container.eContainer();
}
if (!(container instanceof AadlPackage)) {
error(statement, "Enumerations can be defined only in AADL packages");
}
}
use of com.rockwellcollins.atc.agree.agree.NamedID 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");
}
}
}
Aggregations