Search in sources :

Example 16 with NamedID

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");
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) AadlPackage(org.osate.aadl2.AadlPackage) EObject(org.eclipse.emf.ecore.EObject) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) Check(org.eclipse.xtext.validation.Check)

Example 17 with NamedID

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");
        }
    }
}
Also used : NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) DataImplementation(org.osate.aadl2.DataImplementation) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) Check(org.eclipse.xtext.validation.Check)

Aggregations

NamedID (com.rockwellcollins.atc.agree.agree.NamedID)17 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)6 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)6 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)6 AgreeTypeSystem (com.rockwellcollins.atc.agree.AgreeTypeSystem)5 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)5 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)5 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)5 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)5 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)5 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)5 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)5 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)5 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)5 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)5 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)5 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)5 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)5 IndicesExpr (com.rockwellcollins.atc.agree.agree.IndicesExpr)5 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)5