Search in sources :

Example 26 with PropertySet

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;
        }
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) URI(org.eclipse.emf.common.util.URI) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) PropertySet(org.osate.aadl2.PropertySet) UiUtil(org.osate.ui.UiUtil) PropertyAssociation(org.osate.aadl2.PropertyAssociation) Stream(java.util.stream.Stream) Classifier(org.osate.aadl2.Classifier) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Resource(org.eclipse.emf.ecore.resource.Resource) IFile(org.eclipse.core.resources.IFile) ClassifierFeature(org.osate.aadl2.ClassifierFeature) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) AnnexLibrary(org.osate.aadl2.AnnexLibrary) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) ContributedAadlStorage(org.osate.xtext.aadl2.ui.resource.ContributedAadlStorage) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) AadlPackage(org.osate.aadl2.AadlPackage) PropertyAssociation(org.osate.aadl2.PropertyAssociation) PackageSection(org.osate.aadl2.PackageSection) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Classifier(org.osate.aadl2.Classifier) ClassifierFeature(org.osate.aadl2.ClassifierFeature) ContributedAadlStorage(org.osate.xtext.aadl2.ui.resource.ContributedAadlStorage) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) EObject(org.eclipse.emf.ecore.EObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertySet(org.osate.aadl2.PropertySet) AnnexLibrary(org.osate.aadl2.AnnexLibrary)

Example 27 with PropertySet

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());
        }
    }
}
Also used : PropertySet(org.osate.aadl2.PropertySet) PropertyType(org.osate.aadl2.PropertyType) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) Namespace(org.osate.aadl2.Namespace)

Example 28 with PropertySet

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;
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) ModelUnit(org.osate.aadl2.ModelUnit) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) PropertySet(org.osate.aadl2.PropertySet)

Example 29 with PropertySet

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;
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) Subcomponent(org.osate.aadl2.Subcomponent) IScope(org.eclipse.xtext.scoping.IScope) PropertySet(org.osate.aadl2.PropertySet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) Property(org.osate.aadl2.Property) NamedElement(org.osate.aadl2.NamedElement)

Example 30 with PropertySet

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;
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) PropertySet(org.osate.aadl2.PropertySet) Namespace(org.osate.aadl2.Namespace)

Aggregations

PropertySet (org.osate.aadl2.PropertySet)23 AadlPackage (org.osate.aadl2.AadlPackage)15 EObject (org.eclipse.emf.ecore.EObject)10 ArrayList (java.util.ArrayList)8 Property (org.osate.aadl2.Property)8 Classifier (org.osate.aadl2.Classifier)7 Element (org.osate.aadl2.Element)7 ModelUnit (org.osate.aadl2.ModelUnit)7 EList (org.eclipse.emf.common.util.EList)6 PropertyAssociation (org.osate.aadl2.PropertyAssociation)6 List (java.util.List)5 NamedElement (org.osate.aadl2.NamedElement)5 Resource (org.eclipse.emf.ecore.resource.Resource)4 AnnexLibrary (org.osate.aadl2.AnnexLibrary)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 PackageSection (org.osate.aadl2.PackageSection)4 PropertyConstant (org.osate.aadl2.PropertyConstant)4 PropertyType (org.osate.aadl2.PropertyType)4 Stream (java.util.stream.Stream)3 URI (org.eclipse.emf.common.util.URI)3