use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.
the class AssignStatementImpl method setId.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setId(NamedElement newId) {
NamedElement oldId = id;
id = newId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AgreePackage.ASSIGN_STATEMENT__ID, oldId, id));
}
use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.
the class AgreeAnnexContentAssist method getNestedDotIDCandidates.
private List<String> getNestedDotIDCandidates(SelectionExpr id) {
NamedElement base = ((NamedElmExpr) id).getElm();
NamedElement namedEl = null;
if (base instanceof Arg) {
Type type = ((Arg) base).getType();
DoubleDotRef elID = ((DoubleDotRef) type);
namedEl = elID.getElm();
// =======
// DoubleDotRef elID = ((RecordType) type).getRecord();
// namedEl = elID.getElm();
// >>>>>>> origin/develop
} else if (base instanceof DataPort) {
namedEl = ((DataPort) base).getDataFeatureClassifier();
} else if (base instanceof EventDataPort) {
namedEl = ((EventDataPort) base).getDataFeatureClassifier();
} else if (base instanceof AadlPackage) {
return getNestedDotIDCandidates((AadlPackage) base);
} else {
return new ArrayList<>();
}
return getNestedDotIDCandidates(namedEl);
}
use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.
the class AgreeValidator method getEnumValueDefLocation.
private String getEnumValueDefLocation(NamedID id) {
EObject container = id.eContainer();
EnumStatement enumStatement = (EnumStatement) container;
String enumName = enumStatement.getName();
while (!(container instanceof AadlPackage) && !(container instanceof ComponentClassifier)) {
container = container.eContainer();
}
return ((NamedElement) container).getQualifiedName() + "::" + enumName;
}
use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.
the class AgreeValidator method getArgNames.
private List<NamedElement> getArgNames(DoubleDotRef recType) {
NamedElement rec = recType.getElm();
// =======
// private List<NamedElement> getArgNames(DoubleDotRef recId) {
//
// NamedElement rec = recId.getElm();
// >>>>>>> origin/develop
List<NamedElement> names = new ArrayList<>();
if (rec instanceof RecordDef) {
RecordDef recDef = (RecordDef) rec;
for (Arg arg : recDef.getArgs()) {
names.add(arg);
}
} else if (rec instanceof DataImplementation) {
DataImplementation dataImpl = (DataImplementation) rec;
for (Subcomponent sub : dataImpl.getAllSubcomponents()) {
names.add(sub);
}
} else {
error(recType, "Record type '" + rec.getName() + "' must be a feature group or a record type definition");
}
return names;
}
use of org.osate.aadl2.NamedElement in project AGREE by loonwerks.
the class AgreeValidator method checkConstStatement.
@Check(CheckType.FAST)
public void checkConstStatement(ConstStatement constStat) {
TypeDef expected = AgreeTypeSystem.typeDefFromType(constStat.getType());
TypeDef actual = AgreeTypeSystem.infer(constStat.getExpr());
if (!AgreeTypeSystem.typesEqual(expected, actual)) {
error(constStat, "The assumed type of constant statement '" + constStat.getName() + "' is '" + expected + "' but the actual type is '" + actual + "'");
}
// check for constant cycles
Set<ConstStatement> constClosure = new HashSet<>();
Set<ConstStatement> prevClosure;
constClosure.add(constStat);
// quick and dirty cycle check
do {
prevClosure = new HashSet<>(constClosure);
for (ConstStatement constFrontElem : prevClosure) {
List<SelectionExpr> nestIds = EcoreUtil2.getAllContentsOfType(constFrontElem, SelectionExpr.class);
for (Expr nestId : nestIds) {
while (nestId instanceof SelectionExpr) {
NamedElement base = ((SelectionExpr) nestId).getField();
if (base instanceof ConstStatement) {
ConstStatement closConst = (ConstStatement) base;
if (closConst.equals(constStat)) {
error(constStat, "The expression for constant statment '" + constStat.getName() + "' is part of a cyclic definition");
break;
}
constClosure.add(closConst);
}
nestId = ((SelectionExpr) nestId).getTarget();
}
NamedElement base = ((NamedElmExpr) nestId).getElm();
if (base instanceof ConstStatement) {
ConstStatement closConst = (ConstStatement) base;
if (closConst.equals(constStat)) {
error(constStat, "The expression for constant statment '" + constStat.getName() + "' is part of a cyclic definition");
break;
}
constClosure.add(closConst);
}
}
}
} while (!prevClosure.equals(constClosure));
for (Expr e : EcoreUtil2.getAllContentsOfType(constStat.getExpr(), Expr.class)) {
if (!exprIsConstant(e)) {
error(e, "Non-constant expression in constant declaration");
return;
}
}
}
Aggregations