Suppose that I want to provide a diagram only containing Components. If a Component depends on one ore more Interfaces provided by another Component, I want to draw an edge. The label of that edge should consist of the names of the interfaces representing the relationship between the components.

Then I want to have diagram consisting of three nodes representing A, B and C. Between A and B, an edge should be drawn with the label '[IB1 IB2]' and between A and C, an edge should be drawn labeled '[IC1]'.

In order to draw the edge between two components, I used a target finder expression like: [self.dependsOn.eContainer()/] This results in the component providing the interface self depends on.

However, if I want to provide an expression that generates the label of the edge, I'm running into problems: [self.dependsOn.name/] clearly is wrong. That one will result in all interface names (including IC2 where A is not depending on).

> I have a problem defining the expression that gives the correct label
> for an relation based edge.
[snip]
> I'm looking for an expression like: [self.dependsOn->select(i |
> target.provides->includes(i)).name/]
>
> However, 'target' is not available as a variable.
>
> How can I solve this?

I've just tried to reproduce the same kind of structure using Ecore, and
it is indeed possible, but definitely not trivial. You were on the right
track, the structure of your expression is correct and you need the
equivalent of "target", i.e. a pointer to the element "at the other end"
of the specific edge for which you are computing the label.

The expression you need to put instead of the non-existing "target"
variable is the following:

It is verbose because OCL needs explicit casting at each navigation
step. Removing these casts for readability we get:

view.targetNode.target

It works like this:
1. It starts from the "view" variable that Sirius supplies. This points
to the model element used by Sirius to represent the graphical edge
itself (it is of type DEdge, from the Sirius metamodel).
2. From there, it find the edge's targetNode. This gives use another
Sirius model element, the one representing the other end of the edge
(the shape representing your component). It is still an element from the
Sirius metamodel (so we need to cast it to DDiagramElement, another
Sirius metamodel type).
3. All Sirius model elements which "stand for" a domain element in your
diagram have a "target" reference to get this semantic element, so we
follow this "target" reference and get the actual Component at the end
of the edge.

So in the end, because your label must be different for each edge, you
can not simply navigate at the level of the domain model but need to
navigate one level "above" in the Sirius model part, from the "view"
variable, and at the end go back to you domain.

I have tried to be clear but I understand that it needs some knowledge
of how Sirius works underneath, so don't hesitate if you need more
explanations.

In the meantime the only source is the metamodel itself, i.e. the
viewpoint.ecore, diagram.ecore, table.ecore and tree.ecore files (note
that we are currently reorganizing things in this area, but it should be
only moving existing stuff in different locations).