Have you ever tried to query a meta-model, i.e. a model consisting of EClasses, EAttributes, and EReferences, against a meta-model pattern? For an example, look here. In this case, we want to look for a certain sub-configuration in an Ecore metamodel, where two EClasses (each having an EAttribute of type EString) are connected by a 0-* EReference.
Use-cases of this technique include meta-transformation, meta-model analysis, higher-order transformations where transformation rules are generated/parameterized by metamodel analysis etc.
We would like to sincerely thank Christian Schweda for the inspiration for this example.
Make sure you run the latest IncQuery tooling and runtime by downloading and installing from the nightly update site.
Check out the source project from GitHub:
The project contains a pattern named SampleQuery. This pattern looks for matches like the picture at the bottom in Ecore Models.
In the first section the pattern filters out two EClasses (XElement,YElement) and the XElement contains a reference to YElement.
The find EReferenceWithStarMultiplicity(Relates); helper pattern filters out references only with star multiplicity.
The find EClassWithEStringAttribute(XElement, Label1); and the find EClassWithEStringAttribute(YElement, Label2); helper pattern filters out EClasses which contains EString.
The neg find IsInECore(XElement); and the neg find IsInECore(YElement); excludes matching to elements located in Ecore.ecore.