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;
}
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;
}
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");
}
}
}
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;
}
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 + "'");
}
}
}
Aggregations