use of org.osate.aadl2.PropertySet in project osate2 by osate.
the class AadlElementContentProvider method hasChildren.
@Override
public boolean hasChildren(Object element) {
if (element instanceof IFile || element instanceof ContributedAadlStorage) {
return true;
} else {
EObjectURIWrapper wrapper = (EObjectURIWrapper) element;
EObject eObject = new ResourceSetImpl().getEObject(wrapper.getUri(), true);
if (eObject instanceof AadlPackage || eObject instanceof PropertySet || eObject instanceof ComponentInstance) {
return eObject.eContents().stream().anyMatch(member -> !(member instanceof SystemOperationMode || member instanceof PropertyAssociation));
} else if (eObject instanceof PackageSection) {
return eObject.eContents().stream().anyMatch(member -> member instanceof Classifier || member instanceof AnnexLibrary);
} else if (eObject instanceof Classifier) {
return eObject.eContents().stream().anyMatch(member -> member instanceof ClassifierFeature || member instanceof PropertyAssociation);
} else {
return false;
}
}
}
use of org.osate.aadl2.PropertySet in project osate2 by osate.
the class PropertiesValidator method checkPropertySetElementReference.
public void checkPropertySetElementReference(NamedElement pse, Element context) {
if (Aadl2Util.isNull(pse)) {
return;
}
Namespace contextNS = AadlUtil.getContainingTopLevelNamespace(context);
PropertySet referenceNS = (PropertySet) AadlUtil.getContainingTopLevelNamespace(pse);
if (contextNS != referenceNS) {
if (!AadlUtil.isImportedPropertySet(referenceNS, contextNS)) {
error("The referenced property set '" + referenceNS.getName() + "' of " + (pse instanceof Property ? "property '" : (pse instanceof PropertyType ? "property type '" : "property constant '")) + pse.getName() + "' is not listed in a with clause.", context, null, MISSING_WITH, referenceNS.getName(), EcoreUtil.getURI(referenceNS).toString(), EcoreUtil.getURI(contextNS).toString());
}
}
}
use of org.osate.aadl2.PropertySet in project osate2 by osate.
the class OrganizeWithHandler method findMissingWiths.
private List<ModelUnit> findMissingWiths(PackageSection pkgSection) {
List<ModelUnit> currentWiths = pkgSection.getImportedUnits();
List<ModelUnit> missingWiths = new ArrayList<ModelUnit>();
TreeIterator<EObject> packageContents = pkgSection.eAllContents();
while (packageContents.hasNext()) {
EObject nextObject = packageContents.next();
EList<EObject> crossReferences = nextObject.eCrossReferences();
for (EObject crossReference : crossReferences) {
EObject container = crossReference.eContainer();
while (container != null) {
if ((container instanceof PropertySet || container instanceof AadlPackage) && (!AadlUtil.isPredeclaredPropertySet(((ModelUnit) container).getName())) && (!((ModelUnit) container).equals(pkgSection.eContainer()))) {
if (!currentWiths.contains(container) && !missingWiths.contains(container)) {
missingWiths.add((ModelUnit) container);
}
}
container = container.eContainer();
}
}
}
return missingWiths;
}
use of org.osate.aadl2.PropertySet in project AGREE by loonwerks.
the class AgreeScopeProvider method scope_GetPropertyExpr_prop.
protected IScope scope_GetPropertyExpr_prop(GetPropertyExpr ctx, EReference ref) {
IScope prevScope = prevScope(ctx, ref);
ComponentRef cr = ctx.getComponentRef();
if (cr instanceof ThisRef) {
List<Property> ps = new ArrayList<>();
EObject container = ctx.getContainingClassifier();
while (container != null) {
if (container instanceof Classifier) {
List<PropertyAssociation> pas = ((Classifier) container).getAllPropertyAssociations();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
container = ((Classifier) container).eContainer();
} else if (container instanceof AadlPackage) {
for (PropertySet propSet : EcoreUtil2.getAllContentsOfType(container, PropertySet.class)) {
for (Property p : propSet.getOwnedProperties()) {
ps.add(p);
}
// =======
// EList<EObject> refs = null;
//
// if (container instanceof NestedDotID) {
// NestedDotID parent = (NestedDotID) container;
// refs = parent.eCrossReferences();
//
// if (refs.size() != 1) {
// return new HashSet<>(); // this will throw a parsing error
// }
// container = refs.get(0); // figure out what this type this portion
//
// // of the nest id is so we can figure out
// // what we could possibly link to
//
// if (container instanceof ThreadSubcomponent) {
// container = ((ThreadSubcomponent) container).getComponentType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Subcomponent) {
// container = ((Subcomponent) container).getComponentImplementation();
// if (container == null) { // no implementation is provided
// container = refs.get(0);
// container = ((Subcomponent) container).getClassifier();
// }
// result.addAll(getAadlElements(container));
// } else if (container instanceof DataPort) {
// container = ((DataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof EventDataPort) {
// container = ((EventDataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof AadlPackage) {
// result.addAll(getAadlElements(container));
// } else if (container instanceof FeatureGroupImpl) {
// container = ((FeatureGroupImpl) container).getAllFeatureGroupType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Arg || container instanceof ConstStatement) {
// Type type;
//
// if (container instanceof Arg) {
// type = ((Arg) container).getType();
// } else {
// type = ((ConstStatement) container).getType();
// }
//
// if (type instanceof RecordType) {
// DoubleDotRef elID = ((RecordType) type).getRecord();
// NamedElement namedEl = elID.getElm();
//
// if (namedEl instanceof ComponentImplementation) {
// ComponentImplementation componentImplementation = (ComponentImplementation) namedEl;
// EList<Subcomponent> subs = componentImplementation.getAllSubcomponents();
// result.addAll(subs);
// } else if (namedEl instanceof RecordDefExpr) {
// result.addAll(((RecordDefExpr) namedEl).getArgs());
// >>>>>>> origin/develop
}
container = null;
} else {
container = container.eContainer();
}
}
return Scopes.scopeFor(ps, prevScope);
} else if (cr instanceof DoubleDotRef) {
NamedElement ne = ((DoubleDotRef) cr).getElm();
if (ne instanceof Subcomponent) {
List<PropertyAssociation> pas = ((Subcomponent) ne).getOwnedPropertyAssociations();
List<Property> ps = new ArrayList<>();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
return Scopes.scopeFor(ps, prevScope);
}
}
return IScope.NULLSCOPE;
}
use of org.osate.aadl2.PropertySet in project AGREE by loonwerks.
the class AgreeCrossReferenceSerializer method qualifiedName.
private String qualifiedName(Namespace namespace, NamedElement base) {
String defName = base.getName();
String prefix = "";
Namespace defNamespace = AadlUtil.getContainingTopLevelNamespace(base);
String pkgName = defNamespace.getElementRoot().getName();
PropertySet propSet = AadlUtil.findImportedPropertySet(pkgName, namespace);
AadlPackage aadlPackage = AadlUtil.findImportedPackage(pkgName, namespace);
if (propSet != null || aadlPackage != null) {
prefix = pkgName + "::";
}
return prefix + defName;
}
Aggregations