Search in sources :

Example 11 with RecordDef

use of com.rockwellcollins.atc.agree.agree.RecordDef in project AGREE by loonwerks.

the class AgreeAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(NamedElement namedEl) {
    List<String> results = new ArrayList<>();
    List<NamedElement> namedEls = new ArrayList<>();
    if (namedEl instanceof ComponentImplementation) {
        namedEls.addAll(((ComponentImplementation) namedEl).getAllSubcomponents());
    } else if (namedEl instanceof RecordDef) {
        namedEls.addAll(((RecordDef) namedEl).getArgs());
    }
    for (NamedElement el : namedEls) {
        results.add(el.getName());
    }
    return results;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ArrayList(java.util.ArrayList) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef)

Example 12 with RecordDef

use of com.rockwellcollins.atc.agree.agree.RecordDef in project AGREE by loonwerks.

the class AgreeScopeProvider method scope_RecordLitExpr_args.

IScope scope_RecordLitExpr_args(RecordLitExpr ctx, EReference ref) {
    IScope prevScope = prevScope(ctx, ref);
    NamedElement recDef = ctx.getRecordType().getElm();
    Set<Element> components = new HashSet<>();
    if (recDef instanceof DataImplementation) {
        components.addAll(((DataImplementation) recDef).getAllSubcomponents());
        return Scopes.scopeFor(components, prevScope);
    } else if (recDef instanceof RecordDef) {
        components.addAll(((RecordDef) recDef).getArgs());
        return Scopes.scopeFor(components, prevScope);
    }
    return prevScope;
}
Also used : Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) IScope(org.eclipse.xtext.scoping.IScope) DataImplementation(org.osate.aadl2.DataImplementation) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) HashSet(java.util.HashSet)

Example 13 with RecordDef

use of com.rockwellcollins.atc.agree.agree.RecordDef 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)

Example 14 with RecordDef

use of com.rockwellcollins.atc.agree.agree.RecordDef in project AGREE by loonwerks.

the class AgreeValidator method getParentNames.

private Set<String> getParentNames(ComponentImplementation ci) {
    Set<String> result = new HashSet<>();
    ComponentType ct = ci.getType();
    for (AgreeSubclause subclause : EcoreUtil2.getAllContentsOfType(ct, AgreeSubclause.class)) {
        List<NamedElement> es = EcoreUtil2.getAllContentsOfType(subclause, NamedElement.class);
        for (NamedElement e : es) {
            if (!(e.eContainer() instanceof NodeDef || e.eContainer() instanceof LinearizationDef || e.eContainer() instanceof RecordDef || e instanceof NamedSpecStatement)) {
                result.add(e.getName());
            }
        }
    }
    return result;
}
Also used : AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) ComponentType(org.osate.aadl2.ComponentType) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) HashSet(java.util.HashSet)

Example 15 with RecordDef

use of com.rockwellcollins.atc.agree.agree.RecordDef in project AGREE by loonwerks.

the class AgreeValidator method checkRecordLitExpr.

@Check(CheckType.FAST)
public void checkRecordLitExpr(RecordLitExpr recExpr) {
    DoubleDotRef recType = recExpr.getRecordType();
    // =======
    // DoubleDotRef recType = recExpr.getRecord();
    // >>>>>>> origin/develop
    List<NamedElement> defArgs = getArgNames(recType);
    EList<NamedElement> exprArgs = recExpr.getArgs();
    EList<Expr> argExprs = recExpr.getArgExpr();
    NamedElement finalId = recExpr.getRecordType().getElm();
    if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDef)) {
        error(recType, "types must be record definition or data implementation");
    // =======
    // DoubleDotRef recId = recExpr.getRecord();
    // NamedElement finalId = recId.getElm();
    // 
    // if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDefExpr)) {
    // error(recId, "types must be record definition or data implementation");
    // }
    // 
    // if (finalId instanceof DataImplementation) {
    // dataImplCycleCheck(recId);
    // >>>>>>> origin/develop
    }
    if (exprArgs.size() != defArgs.size()) {
        error(recExpr, "Incorrect number of arguments");
        return;
    }
    for (NamedElement argDefName : defArgs) {
        boolean foundArg = false;
        for (NamedElement argExprEl : exprArgs) {
            if (argExprEl.getName().equals(argDefName.getName())) {
                foundArg = true;
                break;
            }
        }
        if (!foundArg) {
            error(recExpr, "No assignment to defined variable '" + argDefName + "' in record expression.");
        }
    }
    // check typing
    Map<String, TypeDef> argNameMap = getFieldTypes(recType);
    for (int i = 0; i < recExpr.getArgs().size(); i++) {
        NamedElement actArg = recExpr.getArgs().get(i);
        String actArgName = actArg.getName();
        TypeDef defType = argNameMap.get(actArgName);
        checkTypeExists(argExprs.get(i));
        TypeDef exprType = AgreeTypeSystem.infer(argExprs.get(i));
        if (!AgreeTypeSystem.typesEqual(defType, exprType)) {
            error(recExpr, "The expression assigned to '" + actArgName + "' does not match its definition type of '" + defType + "'");
        }
    }
}
Also used : DataImplementation(org.osate.aadl2.DataImplementation) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) Check(org.eclipse.xtext.validation.Check)

Aggregations

RecordDef (com.rockwellcollins.atc.agree.agree.RecordDef)15 NamedElement (org.osate.aadl2.NamedElement)11 DataImplementation (org.osate.aadl2.DataImplementation)7 Arg (com.rockwellcollins.atc.agree.agree.Arg)5 NodeDef (com.rockwellcollins.atc.agree.agree.NodeDef)5 Check (org.eclipse.xtext.validation.Check)5 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)4 EnumStatement (com.rockwellcollins.atc.agree.agree.EnumStatement)4 NamedID (com.rockwellcollins.atc.agree.agree.NamedID)4 HashSet (java.util.HashSet)4 Element (org.osate.aadl2.Element)4 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)3 FnDef (com.rockwellcollins.atc.agree.agree.FnDef)3 LibraryFnDef (com.rockwellcollins.atc.agree.agree.LibraryFnDef)3 LinearizationDef (com.rockwellcollins.atc.agree.agree.LinearizationDef)3 ArrayList (java.util.ArrayList)3 ComponentType (org.osate.aadl2.ComponentType)3 ArrayTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef)2 RecordTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)2 TypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef)2