Hello Jan,
unfortunately, the short answer is no.
I have also ran into the same issue at some point. The main thing to understand here is that EMF-Incquery has a query language for EMF models, not Java objects. Therefore, since eContainer is not a feature, you cannot put it into a pattern. The similar is true for eClass. Also, what you are trying to describe is something like what we call "metaquery" (
https://github.com/ujhelyiz/EMF-IncQuery/issues/95), which is not yet supported.
What you can do is either query a metamodel or query an instance model, it is not really supported to combine the two at the moment.
For example, you can create (actually, you already did, as far as I remember) queries that look at features in the metamodel and select them if they are containment:
pattern containmentRef(Host: EClass, Ref : EReference, Target){...}
You can also create a query, that uses a given feature to traverse the model:
pattern someRef(From, To){
FromClass.ref(From,To);
}
But you would need metaqueries to create a combination:
pattern traverse(From, To){
<FromClass>(From);
<ToClass>(To);
find containmentRef(FromClass, Ref, ToClass);
<FromClass>.<Ref>(From, To);
}
Two additional comments:
1. We had support for the containment hierarchy in the pattern language of VIATRA2, but it was quite inefficient.
2. If you only want to traverse a model upwards from a given element, then you're probably better of just writing it in Java. However, if you want to query all EObjects that are under the instances of the given EClass and want to get incremental updates when the list changes, that's more problematic.
We may be able to come up with a solution to this specific case before supporting metaqueries, but I can't give you an easy workaround at this point. Maybe someone else will propose a better solution, this is a mail group after all :)
Best regards,