Search in sources :

Example 16 with FeatureGroupPrototype

use of org.osate.aadl2.FeatureGroupPrototype in project osate2 by osate.

the class PrototypesModel method setPrototypeType.

@Override
public void setPrototypeType(final EditablePrototype prototype, final PrototypeType value) {
    // Check if the type is different by comparing EClass values
    final EClass currentEClass = prototype.prototype.eClass();
    final EClass newEClass = prototypeTypeToEClass(value);
    if (newEClass == currentEClass) {
        return;
    }
    modifyOwningClassifier("Set Prototype Type", prototype, c -> {
        getPrototypeByName(c, prototype.name).ifPresent(p -> {
            // Store location in list
            final int index = c.getOwnedPrototypes().indexOf(p);
            if (index == -1) {
                throw new RuntimeException("Unable to get index of prototype being modified");
            }
            // Store fields
            final String name = p.getName();
            final Prototype refined = p.getRefined();
            ComponentClassifier cc = null;
            FeatureGroupType fgt = null;
            boolean in = false;
            boolean out = false;
            boolean array = false;
            if (p instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) p;
                cc = cp.getConstrainingClassifier();
                array = cp.isArray();
            } else if (p instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) p;
                fgt = fp.getConstrainingFeatureGroupType();
            } else if (p instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) p;
                cc = fp.getConstrainingClassifier();
                in = fp.isIn();
                out = fp.isOut();
            }
            // Create new prototype
            final Prototype newPrototype = (Prototype) EcoreUtil.create(newEClass);
            c.getOwnedPrototypes().add(index, newPrototype);
            if (refined == null) {
                newPrototype.setName(name);
            } else {
                newPrototype.setRefined(refined);
            }
            // Set fields
            if (newPrototype instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) newPrototype;
                cp.setConstrainingClassifier(cc);
                cp.setArray(array);
            } else if (newPrototype instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) newPrototype;
                fp.setConstrainingFeatureGroupType(fgt);
            } else if (newPrototype instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) newPrototype;
                fp.setConstrainingClassifier(cc);
                fp.setIn(in);
                fp.setOut(out);
            }
            // Move property associations
            newPrototype.getOwnedPropertyAssociations().addAll(p.getOwnedPropertyAssociations());
            // Remove old prototype
            EcoreUtil.remove(p);
        });
    });
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EClass(org.eclipse.emf.ecore.EClass) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) MemoryPrototype(org.osate.aadl2.MemoryPrototype) Prototype(org.osate.aadl2.Prototype) ThreadPrototype(org.osate.aadl2.ThreadPrototype) VirtualProcessorPrototype(org.osate.aadl2.VirtualProcessorPrototype) SystemPrototype(org.osate.aadl2.SystemPrototype) VirtualBusPrototype(org.osate.aadl2.VirtualBusPrototype) ProcessPrototype(org.osate.aadl2.ProcessPrototype) ThreadGroupPrototype(org.osate.aadl2.ThreadGroupPrototype) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 17 with FeatureGroupPrototype

use of org.osate.aadl2.FeatureGroupPrototype in project osate2 by osate.

the class FeatureReferenceBindingType method getClassifierOptions.

@Override
public final Stream<NamedElementOrDescription> getClassifierOptions(final PrototypeBindingsModelNode node) {
    if (node == null) {
        return getClassifierOptionsForRoot();
    }
    final Object bo = data(node).bo;
    if (bo == null) {
        return Stream.empty();
    }
    final PrototypeBindingType type = getType(node);
    // Determine which EClasses and prototypes to show
    Stream<EClass> filterEClasses;
    Class<?> prototypeFilter;
    boolean includeNull = true;
    if (bo instanceof ComponentPrototype) {
        final ComponentCategory category = ((ComponentPrototype) bo).getCategory();
        filterEClasses = componentCategoryToPrototypeFilterTypeEClasses(category);
        prototypeFilter = ComponentPrototype.class;
    } else if (bo instanceof FeatureGroupPrototype) {
        filterEClasses = Stream.of(Aadl2Package.eINSTANCE.getFeatureGroupType());
        prototypeFilter = FeatureGroupPrototype.class;
    } else if (bo instanceof FeaturePrototype && type instanceof AccessSpecificationBindingType || type instanceof PortSpecificationBindingType) {
        filterEClasses = Stream.of(Aadl2Package.eINSTANCE.getComponentClassifier());
        prototypeFilter = null;
    } else if (bo instanceof FeaturePrototype && type instanceof FeatureReferenceBindingType) {
        filterEClasses = Stream.empty();
        prototypeFilter = FeaturePrototype.class;
        includeNull = false;
    } else {
        filterEClasses = Stream.empty();
        prototypeFilter = null;
        includeNull = false;
    }
    Stream<NamedElementOrDescription> options = includeNull ? Stream.of((NamedElementOrDescription) null) : Stream.empty();
    // Concatenate all classifiers that match the supported EClass
    options = Stream.concat(options, filterEClasses.flatMap(eclass -> AadlModelAccessUtil.getAllEObjectsByType(project, eclass).stream().map(NamedElementOrDescription::new)));
    // Show appropriate prototypes
    if (prototypeFilter != null) {
        options = Stream.concat(options, getReferenceablePrototypes().filter(prototypeFilter::isInstance).map(NamedElementOrDescription::new));
    }
    return options;
}
Also used : ComponentCategory(org.osate.aadl2.ComponentCategory) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FeaturePrototype(org.osate.aadl2.FeaturePrototype) EObject(org.eclipse.emf.ecore.EObject)

Example 18 with FeatureGroupPrototype

use of org.osate.aadl2.FeatureGroupPrototype in project osate2 by osate.

the class ResolvePrototypeUtil method resolveFeatureGroupPrototype.

/**
 * Find the binding for a given feature group prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context of the feature group in which the prototype is used, e.g., a
 *            ComponentType, FeatureGroupType, ContainmentPathElement
 * @return The feature group prototype actual the prototype is bound to.
 */
public static FeatureGroupType resolveFeatureGroupPrototype(FeatureGroupPrototype proto, Element context) {
    FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) resolvePrototype(proto, context);
    if (fgpb == null) {
        // look for constraining classifier
        FeatureGroupPrototype refinedPrototype = proto;
        while (refinedPrototype.getConstrainingFeatureGroupType() != null && refinedPrototype.getRefined() instanceof FeatureGroupPrototype) {
            refinedPrototype = (FeatureGroupPrototype) refinedPrototype.getRefined();
        }
        if (refinedPrototype.getConstrainingFeatureGroupType() != null) {
            return refinedPrototype.getConstrainingFeatureGroupType();
        } else {
            return null;
        }
    }
    FeatureGroupPrototypeActual actual = fgpb.getActual();
    if (actual.getFeatureType() instanceof FeatureGroupType) {
        return (FeatureGroupType) actual.getFeatureType();
    } else {
        if (actual.getFeatureType() instanceof Prototype && context instanceof ContainmentPathElement) {
            // resolve recursively if we are in a containment path
            return resolveFeatureGroupPrototype((FeatureGroupPrototype) actual.getFeatureType(), getPrevious((ContainmentPathElement) context));
        }
    }
    return null;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual)

Example 19 with FeatureGroupPrototype

use of org.osate.aadl2.FeatureGroupPrototype in project osate2 by osate.

the class Aadl2LinkingService method doGetLinkedObjects.

private List<EObject> doGetLinkedObjects(EObject context, EReference reference, INode node) throws IllegalNodeException {
    NamedElement annex = AadlUtil.getContainingAnnex(context);
    if (annex != null && !(reference == Aadl2Package.eINSTANCE.getModalElement_InMode())) {
        String annexName = annex.getName();
        if (annexName != null) {
            if (annexlinkingserviceregistry == null) {
                initAnnexLinkingServiceRegistry();
            }
            if (annexlinkingserviceregistry != null) {
                AnnexLinkingService linkingservice = annexlinkingserviceregistry.getAnnexLinkingService(annexName);
                if (linkingservice != null) {
                    return linkingservice.resolveAnnexReference(annexName, context, reference, node);
                }
            }
        }
        return Collections.<EObject>emptyList();
    }
    final EClass requiredType = reference.getEReferenceType();
    if (requiredType == null) {
        return Collections.<EObject>emptyList();
    }
    Aadl2Package.eINSTANCE.getPropertyType();
    final EClass cl = Aadl2Package.eINSTANCE.getClassifier();
    final EClass sct = Aadl2Package.eINSTANCE.getSubcomponentType();
    final String name = getCrossRefNodeAsString(node);
    if (sct.isSuperTypeOf(requiredType) || cl.isSuperTypeOf(requiredType)) {
        // XXX: this code can be replicated in Aadl2LinkingService as it is called often in the core
        // resolve classifier reference
        EObject e = findClassifier(context, reference, name);
        if (e != null) {
            // the result satisfied the expected class
            return Collections.singletonList(e);
        }
        if (!(context instanceof Generalization) && sct.isSuperTypeOf(requiredType)) {
            // need to resolve prototype
            Classifier containingClassifier = AadlUtil.getContainingClassifier(context);
            /*
				 * This test was put here as a quick and dirty fix to a NullPointerException that was
				 * being thrown while typing up a component type renames statement. Need to figure out
				 * what we should really be doing for renames.
				 */
            if (containingClassifier != null) {
                EObject res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
                if (Aadl2Package.eINSTANCE.getDataPrototype() == reference) {
                    if (res instanceof DataPrototype) {
                        return Collections.singletonList(res);
                    }
                } else if (res instanceof ComponentPrototype) {
                    return Collections.singletonList(res);
                }
            }
        }
        return Collections.emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeatureClassifier().isSuperTypeOf(requiredType)) {
        // prototype for feature or component, or data,bus,subprogram, subprogram group classifier
        EObject e = findClassifier(context, reference, name);
        if (Aadl2Util.isNull(e) && !(context instanceof Generalization) && !Aadl2Package.eINSTANCE.getComponentType().isSuperTypeOf(requiredType)) {
            // look for prototype
            e = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            // TODO-phf: this can be removed if the FeatureClassifier class handles it
            if (!(e instanceof FeaturePrototype || e instanceof ComponentPrototype)) {
                e = null;
            }
        }
        if (e != null && requiredType.isSuperTypeOf(e.eClass())) {
            return Collections.singletonList(e);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeaturePrototype() == requiredType) {
        // look for prototype
        EObject e = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        // TODO-phf: this can be removed if the FeatureClassifier class handles it
        if (e instanceof FeaturePrototype) {
            return Collections.singletonList(e);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getConnectionEnd() == requiredType) {
        // resolve connection end
        ConnectionEnd ce = null;
        if (context.eContainer() instanceof ConnectedElement) {
            ConnectedElement contextParent = (ConnectedElement) context.eContainer();
            if (contextParent.getConnectionEnd() instanceof FeatureGroup) {
                ce = findElementInContext(contextParent, (FeatureGroup) contextParent.getConnectionEnd(), name, ConnectionEnd.class);
            }
        } else {
            ConnectedElement connectedElement = (ConnectedElement) context;
            ce = findElementInContext(connectedElement, connectedElement.getContext(), name, ConnectionEnd.class);
        }
        if (ce != null) {
            return Collections.singletonList((EObject) ce);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getTriggerPort() == requiredType) {
        if (context instanceof ModeTransitionTrigger) {
            ModeTransitionTrigger trigger = (ModeTransitionTrigger) context;
            TriggerPort triggerPort = findElementInContext(trigger, trigger.getContext(), name, TriggerPort.class);
            if (triggerPort != null) {
                return Collections.singletonList((EObject) triggerPort);
            }
        }
        return Collections.emptyList();
    } else if (Aadl2Package.eINSTANCE.getPort().isSuperTypeOf(requiredType)) {
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof Feature) {
            // component being extended
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        // } else if (context instanceof ModeTransitionTrigger){
        // // we are a mode transition trigger
        // Context triggerContext = ((ModeTransitionTrigger)context).getContext();
        // if (triggerContext instanceof Subcomponent){
        // // look up the feature in the ComponentType
        // ComponentType ct = ((Subcomponent)triggerContext).getComponentType();
        // if (ct != null)
        // ns = ct;
        // }
        // if (triggerContext instanceof FeatureGroup){
        // // look up the feature in the FeaturegroupType
        // FeatureGroupType ct = ((FeatureGroup)triggerContext).getFeatureGroupType();
        // if (ct != null)
        // ns = ct;
        // }
        }
        EObject searchResult = AadlUtil.findNamedElementInList(ns.getAllFeatures(), name);
        if (searchResult != null && searchResult instanceof Port) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getContext() == requiredType) {
        // represents connection source/dest context as well as flowspec
        // context
        // also used in triggerport
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult instanceof Context) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getCallContext() == requiredType) {
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
            return Collections.singletonList(searchResult);
        }
        searchResult = findClassifier(context, reference, name);
        if (searchResult != null) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getCalledSubprogram() == requiredType) {
        Classifier ns = AadlUtil.getContainingClassifier(context);
        EObject searchResult;
        if (!(context instanceof SubprogramCall) || (context instanceof SubprogramCall && ((SubprogramCall) context).getContext() == null)) {
            // first check whether it is a reference to a classifier
            searchResult = findClassifier(context, reference, name);
            if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
            // if it was a qualified component type name it would have been found before
            if (name.contains("::")) {
                // Qualified classifier should have been found before
                return Collections.<EObject>emptyList();
            }
            // no package qualifier. Look up in local name space, e.g., subprogram access feature or subprogram subcomponent
            searchResult = ns.findNamedElement(name);
            if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
        }
        // lets first find it in its context
        if (context instanceof SubprogramCall) {
            // we have a context
            // lets set it and find the called subprogram
            SubprogramCall callSpec = (SubprogramCall) context;
            CallContext callContext = callSpec.getContext();
            if (callContext instanceof ComponentType) {
                // first try to find subprogram implementation
                ComponentType ct = (ComponentType) callContext;
                String implname = ct.getQualifiedName() + "." + name;
                searchResult = findClassifier(context, reference, implname);
                if (searchResult != null && searchResult instanceof ComponentImplementation) {
                    return Collections.singletonList(searchResult);
                }
                ns = (ComponentType) callContext;
            } else if (callContext instanceof SubprogramGroupSubcomponent) {
                ns = ((SubprogramGroupSubcomponent) callContext).getComponentType();
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            } else if (callContext instanceof SubprogramGroupAccess && ((SubprogramGroupAccess) callContext).getKind() == AccessType.REQUIRES) {
                SubprogramGroupSubcomponentType sst = ((SubprogramGroupAccess) callContext).getSubprogramGroupFeatureClassifier();
                if (sst instanceof Classifier) {
                    ns = (Classifier) sst;
                }
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            } else if (callContext instanceof FeatureGroup) {
                ns = ((FeatureGroup) callContext).getFeatureGroupType();
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            }
            searchResult = ns.findNamedElement(name);
            if (!Aadl2Util.isNull(searchResult) && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
            // it might be a component implementation. The type is already recorded in the context
            if (callContext instanceof SubprogramType) {
                String contextName = ((SubprogramType) callContext).getName();
                searchResult = findClassifier(context, reference, contextName + "." + name);
                if (!Aadl2Util.isNull(searchResult)) {
                    return Collections.singletonList(searchResult);
                }
                return Collections.<EObject>emptyList();
            }
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getPrototype() == requiredType) {
        // if context prototype then find in extension source (refined)
        // prototype binding as context
        EObject searchResult = null;
        Classifier ns = null;
        if (context.eContainer() instanceof Subcomponent) {
            Subcomponent sub = (Subcomponent) context.eContainer();
            ns = sub.getAllClassifier();
            if (!Aadl2Util.isNull(ns)) {
                searchResult = ns.findNamedElement(name);
            }
        } else if (context.eContainer() instanceof ComponentPrototypeActual) {
            ComponentPrototypeActual cpa = (ComponentPrototypeActual) context.eContainer();
            SubcomponentType subT = cpa.getSubcomponentType();
            if (subT instanceof ComponentClassifier) {
                searchResult = ((ComponentClassifier) subT).findNamedElement(name);
            }
        } else if (context.eContainer() instanceof FeatureGroupPrototypeActual) {
            FeatureGroupPrototypeActual cpa = (FeatureGroupPrototypeActual) context.eContainer();
            FeatureType subT = cpa.getFeatureType();
            if (subT instanceof FeatureGroupType) {
                searchResult = ((FeatureGroupType) subT).findNamedElement(name);
            }
        } else if (context.eContainer() instanceof ComponentImplementationReference) {
            ns = ((ComponentImplementationReference) context.eContainer()).getImplementation();
            if (!Aadl2Util.isNull(ns)) {
                searchResult = ns.findNamedElement(name);
            }
        } else {
            // If resolving a prototype binding formal, don't resolve to a local prototype. Go to the generals.
            // We could be in a prototype refinement. Go to the generals so that we don't resolve to context.
            ns = AadlUtil.getContainingClassifier(context);
            for (Iterator<Classifier> iter = ns.getGenerals().iterator(); searchResult == null && iter.hasNext(); ) {
                searchResult = iter.next().findNamedElement(name);
            }
        }
        if (!Aadl2Util.isNull(searchResult) && searchResult instanceof Prototype) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFlowElement() == requiredType) {
        // look for flow element in flow segment
        FlowSegment fs = (FlowSegment) context;
        FlowElement flowElement = findElementInContext(fs, fs.getContext(), name, FlowElement.class);
        if (flowElement != null) {
            return Collections.singletonList((EObject) flowElement);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getEndToEndFlowElement() == requiredType) {
        // look for flow element in flow segment
        EndToEndFlowSegment fs = (EndToEndFlowSegment) context;
        EndToEndFlowElement flowElement = findElementInContext(fs, fs.getContext(), name, EndToEndFlowElement.class);
        if (flowElement != null) {
            return Collections.singletonList((EObject) flowElement);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getModeTransition() == requiredType) {
        // referenced by in modes
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && searchResult instanceof ModeTransition) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getModeFeature() == requiredType) {
        // referenced by inmodes in connections and flows
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && searchResult instanceof ModeFeature) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFlowSpecification() == requiredType) {
        // refined flow spec
        // referenced by flow implementation
        // also referenced in flow elements in impl and etef
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof FlowSpecification) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof FlowSpecification) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getEndToEndFlow() == requiredType) {
        // refined flow spec
        // referenced by flow implementation
        // also referenced in flow elements in impl and etef
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof EndToEndFlow) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof EndToEndFlow) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getConnection() == requiredType) {
        // refined to, flow elements
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof Connection) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof Connection) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeatureType() == requiredType) {
        // feature group type or prototype
        FeatureGroupType fgt = findFeatureGroupType(context, name, reference);
        if (Aadl2Util.isNull(fgt)) {
            // need to resolve prototype
            EObject res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            if (res instanceof FeatureGroupPrototype) {
                return Collections.singletonList(res);
            }
        } else {
            return Collections.singletonList((EObject) fgt);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getArraySizeProperty() == requiredType) {
        // reference to a property constant or property
        // look for property definition in property set
        List<EObject> result = findPropertyDefinitionAsList(context, reference, name);
        if (result.isEmpty()) {
            result = findPropertyConstant(context, reference, name);
        }
        return result;
    } else {
        List<EObject> res = super.getLinkedObjects(context, reference, node);
        return res;
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureType(org.osate.aadl2.FeatureType) FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) DataPrototype(org.osate.aadl2.DataPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) SubcomponentType(org.osate.aadl2.SubcomponentType) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) ModeTransition(org.osate.aadl2.ModeTransition) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) Generalization(org.osate.aadl2.Generalization) Feature(org.osate.aadl2.Feature) ModeFeature(org.osate.aadl2.ModeFeature) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FlowSpecification(org.osate.aadl2.FlowSpecification) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) EObject(org.eclipse.emf.ecore.EObject) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ConnectedElement(org.osate.aadl2.ConnectedElement) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) SubprogramCall(org.osate.aadl2.SubprogramCall) Context(org.osate.aadl2.Context) CallContext(org.osate.aadl2.CallContext) EndToEndFlow(org.osate.aadl2.EndToEndFlow) ComponentType(org.osate.aadl2.ComponentType) ComponentImplementationReference(org.osate.aadl2.ComponentImplementationReference) TriggerPort(org.osate.aadl2.TriggerPort) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) Connection(org.osate.aadl2.Connection) DataPrototype(org.osate.aadl2.DataPrototype) CallContext(org.osate.aadl2.CallContext) SubprogramGroupAccess(org.osate.aadl2.SubprogramGroupAccess) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) AnnexLinkingService(org.osate.annexsupport.AnnexLinkingService) FeaturePrototype(org.osate.aadl2.FeaturePrototype) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) SubprogramType(org.osate.aadl2.SubprogramType) ConnectionEnd(org.osate.aadl2.ConnectionEnd) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) FlowSegment(org.osate.aadl2.FlowSegment) NamedElement(org.osate.aadl2.NamedElement) ModeFeature(org.osate.aadl2.ModeFeature) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Aggregations

FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)18 ComponentPrototype (org.osate.aadl2.ComponentPrototype)15 FeaturePrototype (org.osate.aadl2.FeaturePrototype)11 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)9 FeatureGroupType (org.osate.aadl2.FeatureGroupType)9 Classifier (org.osate.aadl2.Classifier)8 DataPrototype (org.osate.aadl2.DataPrototype)8 Prototype (org.osate.aadl2.Prototype)8 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)7 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)7 EObject (org.eclipse.emf.ecore.EObject)6 FeatureGroup (org.osate.aadl2.FeatureGroup)6 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)6 Subcomponent (org.osate.aadl2.Subcomponent)6 EClass (org.eclipse.emf.ecore.EClass)5 PrototypeBinding (org.osate.aadl2.PrototypeBinding)5 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)4 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)4 Feature (org.osate.aadl2.Feature)4