mbeddr meets IncQuery - Combining the Best Features of Two Modeling Worlds - EclipseCon Europe 2014
We are proud to announce that this year’s EclipseCon again had a talk about EMF-IncQuery, this time in the context of an integration project with a different modeling world. During the summer, we have started to work on the MPS-IncQuery project, which aims to bring IncQuery’s powerful features to the world of the Meta Programming System (MPS) from JetBrains. MPS is a powerful language workbench which is designed to ease the development of domain specific and general purpose languages, plus their IDEs.
The need for this integration project has risen in the context of the mbeddr project (which is developed by itemis). The mbeddr platform is designed for embedded software development as an intelligent IDE (mainly for C) with many higher level abstractions to ease and help all parts of the development process. mbeddr is built on the MPS workbench as a collection of integrated and extensible languages. This makes it easy to customize, reuse and compose the languages to match you own needs and to have the right abstractions at hand when they are needed.
The talk was rather technical, due to the complexity of many projects involved and because we tried to give details on as many of the following challenges as we could:
-
Mapping the Xtext language of the EMF-IncQuery project to the MPS’ world to be able to express the queries right in the workbench.
-
Implementing the code generators for the queries in MPS (MPS is written in Java so we need the resulting Java code to actually use the queries).
-
Providing a type-safe API with an extension to the Java base language of MPS. Here, new statements have been introduced in MPS’ Java language (yes, you can do this too) to access the queries that you have written previously.
-
IncQuery's developer UI, the Query Explorer was also ported to MPS so that debugging of queries is made easier.
-
Implementing the backend which is responsible for handling the notifications coming from the observed MPS models. Here, we tried to reuse as much as possible from the already existing EMF-IncQuery backend. By the way EMF-IncQuery is moving towards the refactoring that all kinds of model representations could be plugged in by simply rewriting the modeling-paradigm-specific parts of the backend (to handle the notifications, for example).
-
We have many use cases in the mbeddr project where we could benefit from the efficient graph queries of IncQuery. This includes assessments on requirements documents (the demo was about this use case), computing scoping information in the IDE to figure out what variables/functions are visible at a given point in the C code or to specify constraints. Additionally, projectional editing brings a whole lot of other usages where live maintenance of graphical viewers is important and response time is crucial for larger diagrams.
We also gave a short live demo during the presentation which was centered around the requirements engineering language of mbeddr. This extension is used by many end users of mbeddr to write requirements documents and create various assessments on them. An assessment is simply a small query which reports certain program elements and constructs which satisfy given conditions. The following screenshots briefly describe the scenario:
-
The requirements document in mbeddr, where you can also see the workpackages with additional properties like responsible company, priority and scope.
- The assessment container and the report inside it. The report has the same properties as the workpackages so that the user can specify the conditions and only those workpackages are listed in the result which meet these conditions.
Additionally here is the query that we have used for the assessment. This establishes a connection between the WorkPackagesAssessmentReport and the WorkPackages. We access the interesting properties (company, priority, scope) of these concepts and use check expressions to specify the conditions when a tuple should appear in the match set of the query.
Finally here you can see parts of the Java code that is used in the language for the assessment. In MPS you can write constraints and behavior methods (basically derived features) for you language in the Java language of MPS. This language has been extended with additional constructs and types (in runtime) to access the matchers for the queries:
Here, we create a matcher for our query and the scope of the query is specified as this.model which will evaluate to the model of the given assessment during “runtime”. Runtime is quite interesting here, because everything happens in the same JVM; query development, code generation and reloading of their classes and using the queries for your own instance model. After this we create a partial match where we set the first parameter to be the assessment and then we retrieve all the values for the second parameter which will be the workpackages found in the model.
Licensing
This integration project supports a dual licensing setup, where MPS is licensed under Apache 2.0, while all the other tools (EMF-IncQuery, MPS-IncQuery) are licensed under Eclipse EPL.
Resources:
-
EclipseCon talk: https://www.eclipsecon.org/europe2014/session/mbeddr-meets-incquery-combining-best-features-two-modeling-worlds
-
mbeddr: mbeddr.com (go to the Learn page to see all the papers on mbeddr)
-
MPS-IncQuery (also includes a simple demo which resembles the school example from the EMF tutorials): https://github.com/szabta89/MPS-IncQuery
-
Meta Programming System: https://www.jetbrains.com/mps/