Search in sources :

Example 21 with ConnectionEnd

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

the class CreateConnectionsSwitch method filterIngoingConnections.

/**
 * get ingoing connections for specified feature
 *
 * @param incomingconnlist
 * @param feature
 *            subcomponent feature that is the source of a connection
 * @return connections with feature as destination
 */
public List<Connection> filterIngoingConnections(SystemInstance si, List<Connection> incomingconnlist, FeatureInstance fi) {
    List<Connection> result = new ArrayList<Connection>(incomingconnlist.size());
    List<Feature> features = fi.getFeature().getAllFeatureRefinements();
    List<Feature> parents;
    for (Connection conn : incomingconnlist) {
        ConnectionEnd srcEnd = conn.getAllSource();
        // then the feature must match the passed-in feature instance
        if (srcEnd instanceof Feature) {
            Context srcCtx = conn.getAllSourceContext();
            if (srcCtx == null && features.contains(srcEnd)) {
                result.add(conn);
            } else if (srcCtx instanceof FeatureGroup && features.contains(srcEnd)) {
                parents = ((FeatureInstance) fi.getOwner()).getFeature().getAllFeatureRefinements();
                if (parents.contains(srcCtx)) {
                    result.add(conn);
                }
            }
        }
        if (conn.isAllBidirectional()) {
            ConnectionEnd dstEnd = conn.getAllDestination();
            // check other end
            if (dstEnd instanceof Feature) {
                Context dstCtx = conn.getAllDestinationContext();
                if (dstCtx == null && features.contains(dstEnd)) {
                    result.add(conn);
                } else if (dstCtx instanceof FeatureGroup && features.contains(dstEnd)) {
                    parents = ((FeatureInstance) fi.getOwner()).getFeature().getAllFeatureRefinements();
                    if (parents.contains(dstCtx)) {
                        result.add(conn);
                    }
                }
            }
        }
    }
    return result;
}
Also used : Context(org.osate.aadl2.Context) FeatureGroup(org.osate.aadl2.FeatureGroup) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection) ArrayList(java.util.ArrayList) ConnectionEnd(org.osate.aadl2.ConnectionEnd) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature)

Example 22 with ConnectionEnd

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

the class CreateEndToEndFlowsSwitch method isValidContinuationConnectionEnd.

private boolean isValidContinuationConnectionEnd(final Context flowCxt, final Feature flowIn, final List<Feature> flowInRefined, final ConnectedElement connElement) {
    boolean result = false;
    final ConnectionEnd connEnd = connElement.getConnectionEnd();
    if (connEnd instanceof Feature) {
        final List<Feature> connEndRefined = ((Feature) connEnd).getAllFeatureRefinements();
        if (flowCxt instanceof FeatureGroup) {
            // src end of the flow is "fg.f"
            result = connEndRefined.contains(flowCxt);
            // if connDestination.getNext() is null then dest end of connection is "fg"
            if (result && connElement.getNext() != null) {
                final ConnectionEnd connEnd2 = connElement.getNext().getConnectionEnd();
                if (connEnd2 instanceof Feature) {
                    // check "fg.f" to "fg.f"
                    final List<Feature> connEndRefined2 = ((Feature) connEnd2).getAllFeatureRefinements();
                    result = flowInRefined.contains(connEnd2) || connEndRefined2.contains(flowIn);
                } else {
                    // Connection doesn't end in feature, so no match
                    result = false;
                }
            }
        } else {
            // checks "f" to "f" or "fg" to "fg"
            result = flowInRefined.contains(connEnd) || connEndRefined.contains(flowIn);
        }
    }
    return result;
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) ConnectionEnd(org.osate.aadl2.ConnectionEnd) Feature(org.osate.aadl2.Feature)

Example 23 with ConnectionEnd

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

the class ConnectionInfo method addSegment.

/**
 * @param newSeg the connection to be appended
 * @param srcFi the feature instance at the source of the new segment
 * @param dstFi the feature instance at the destination of the new
 *            segment
 * @param ci the component containing the new segment
 * @param opposite if we traverse a bidirectional segment opposite to
 *            the declaration order
 * @return if the new segment is a valid continuation of the connection
 *         instance
 */
public boolean addSegment(final Connection newSeg, final ConnectionInstanceEnd srcFi, final ConnectionInstanceEnd dstFi, final ComponentInstance ci, boolean opposite, boolean[] keep) {
    boolean valid = true;
    final Context srcCtx = opposite ? newSeg.getAllDestinationContext() : newSeg.getAllSourceContext();
    final Context dstCtx = opposite ? newSeg.getAllSourceContext() : newSeg.getAllDestinationContext();
    final ConnectionEnd source = opposite ? newSeg.getAllDestination() : newSeg.getAllSource();
    final ConnectionEnd dest = opposite ? newSeg.getAllSource() : newSeg.getAllDestination();
    final boolean goingUp = !(dstCtx instanceof Subcomponent) && (source instanceof Subcomponent || srcCtx instanceof Subcomponent);
    final boolean goingDown = !(srcCtx instanceof Subcomponent) && (dest instanceof Subcomponent || dstCtx instanceof Subcomponent);
    // TODO can we do these checks on the instance information
    keep[0] = true;
    if (srcFi != null) {
        sources.add(srcFi);
        if (srcFi instanceof FeatureInstance) {
            DirectionType dir = ((FeatureInstance) srcFi).getFlowDirection();
            bidirectional &= (dir == DirectionType.IN_OUT);
            if (goingUp) {
                valid &= dir.outgoing();
            } else if (goingDown) {
                valid &= dir.incoming();
            } else {
                valid &= dir.outgoing();
            }
        }
    }
    bidirectional &= newSeg.isAllBidirectional();
    if (dstFi != null) {
        destinations.add(dstFi);
        if (dstFi instanceof FeatureInstance) {
            DirectionType dir = ((FeatureInstance) dstFi).getFlowDirection();
            bidirectional &= (dir == DirectionType.IN_OUT);
            if (goingUp) {
                valid &= dir.outgoing();
            } else if (goingDown) {
                valid &= dir.incoming();
            } else {
                valid &= dir.incoming();
            }
        }
    }
    /*
		 * Issue 582 -- This does not catch all the bad things that can happen. NOT testing for
		 * subcomponents being connected to requires (goingup) or provides (goingdon).
		 */
    // XXX: the argument below, "this.src", may not be correct, but I'm not really sure what is the correct thing
    final ConnectionInstanceEnd resolvedSrc = resolveFeatureInstance(this.src, srcFi);
    // XXX: the argument below, "this.src", may not be correct, but I'm not really sure what is the correct thing
    final ConnectionInstanceEnd resolvedDst = resolveFeatureInstance(this.src, dstFi);
    if (resolvedSrc instanceof FeatureInstance) {
        if (resolvedDst instanceof FeatureInstance) {
            final FeatureInstance resolvedSrcFI = (FeatureInstance) resolvedSrc;
            final FeatureInstance resolvedDstFI = (FeatureInstance) resolvedDst;
            if (resolvedSrcFI.getCategory() == FeatureCategory.DATA_ACCESS && resolvedDstFI.getCategory() == FeatureCategory.DATA_ACCESS) {
                if (goingUp || goingDown) {
                    valid &= resolvedSrcFI.getDirection() == resolvedDstFI.getDirection();
                } else {
                    valid &= resolvedSrcFI.getDirection().getInverseDirection() == resolvedDstFI.getDirection();
                }
            }
        }
    } else {
    // TODO ComponentInstance -- Should check connections between components and access features here
    }
    if (valid) {
        // handle reaching into feature groups in across connection
        if (newSeg.isAcross()) {
            // segment goes across
            int i = connections.size();
            Connection root = newSeg.getRootConnection();
            srcToMatch = opposite ? root.getDestination() : root.getSource();
            srcToMatch = srcToMatch.getNext();
            while (keep[0] && i > 0 && srcToMatch != null) {
                i -= 1;
                Connection c = connections.get(i);
                // skip connections that don't go into a feature group
                if (!connectsSameFeatureGroup(c)) {
                    ConnectionEnd e = opposites.get(i) ? c.getAllSource() : c.getAllDestination();
                    ConnectionEnd cce = srcToMatch.getConnectionEnd();
                    srcToMatch = srcToMatch.getNext();
                    keep[0] = cce == e;
                }
            }
            across = true;
            acrossConnection = newSeg;
            dstToMatch = opposite ? root.getSource() : root.getDestination();
            dstToMatch = dstToMatch.getNext();
            container = ci;
        } else if (across && dstToMatch != null) {
            if (!connectsSameFeatureGroup(newSeg)) {
                ConnectionEnd e = opposite ? newSeg.getAllDestination() : newSeg.getAllSource();
                ConnectionEnd cce = dstToMatch.getConnectionEnd();
                dstToMatch = dstToMatch.getNext();
                keep[0] = cce == e;
            }
        }
    }
    connections.add(newSeg);
    opposites.add(opposite);
    contexts.add(ci);
    return valid;
}
Also used : Context(org.osate.aadl2.Context) DirectionType(org.osate.aadl2.DirectionType) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) ConnectionEnd(org.osate.aadl2.ConnectionEnd)

Example 24 with ConnectionEnd

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

the class ConnectionInstanceImpl method getThroughFeatureInstances.

/**
 * return list of Feature instances involved in a connection instance
 * In case of a fan-in/fan-out it includes both the feature group and the feature
 * For an end point in teh connection it may be a component instance
 */
public List<InstanceObject> getThroughFeatureInstances() {
    final List<InstanceObject> featureList = new ArrayList<InstanceObject>();
    InstanceObject lastDest = null;
    for (ConnectionReference connRef : getConnectionReferences()) {
        Connection conn = connRef.getConnection();
        ComponentInstance ctxt = connRef.getContext();
        final ConnectionEnd srcF = conn.getAllSource();
        final Context srcCtxt = conn.getAllSourceContext();
        final InstanceObject srcInstance = getInstantiatedEndPoint(ctxt, srcF, srcCtxt);
        if (srcInstance != lastDest) {
            featureList.add(srcInstance);
        }
        final ConnectionEnd destF = conn.getAllDestination();
        final Context destCtxt = conn.getAllDestinationContext();
        final InstanceObject destInstance = getInstantiatedEndPoint(ctxt, destF, destCtxt);
        featureList.add(destInstance);
        lastDest = destInstance;
    }
    return featureList;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) Context(org.osate.aadl2.Context) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ArrayList(java.util.ArrayList) Connection(org.osate.aadl2.Connection) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ConnectionEnd(org.osate.aadl2.ConnectionEnd)

Example 25 with ConnectionEnd

use of org.osate.aadl2.ConnectionEnd 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

ConnectionEnd (org.osate.aadl2.ConnectionEnd)22 Connection (org.osate.aadl2.Connection)13 Context (org.osate.aadl2.Context)13 ComponentImplementation (org.osate.aadl2.ComponentImplementation)8 Subcomponent (org.osate.aadl2.Subcomponent)8 ArrayList (java.util.ArrayList)7 Feature (org.osate.aadl2.Feature)7 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)7 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)7 DataSubcomponent (org.osate.aadl2.DataSubcomponent)6 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)6 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)6 BusinessObjectNode (org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode)6 ConnectedElement (org.osate.aadl2.ConnectedElement)5 FeatureGroup (org.osate.aadl2.FeatureGroup)5 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)5 NamedElement (org.osate.aadl2.NamedElement)4 PortConnection (org.osate.aadl2.PortConnection)4 ClassifierMatchingRule (org.osate.aadl2.contrib.modeling.ClassifierMatchingRule)4 InstanceObject (org.osate.aadl2.instance.InstanceObject)4