
A Generic Projectional Editor for EMF Models Johannes Schropfer,¨ Thomas Buchmann and Bernhard Westfechtel Chair of Applied Computer Science I, University of Bayreuth, Universitatsstrasse¨ 30, 95440 Bayreuth, Germany fi[email protected] Keywords: Model-driven Development, Projectional Editing, ALF, Java, Ecore, Syntax-directed Editor, Generic Frame- work. Abstract: The Eclipse Modeling Framework (EMF) constitutes a popular ecosystem for model-driven development. In the technological space of EMF, a wide variety of model-based tools have been developed, including tools for transforming and editing models. Model editors may display models in different representations such as diagrams, trees, or tables. Due to the increasing popularity of human-readable textual syntax, there is a growing demand for textual model editors. In EMF, this demand is currently satisfied by syntax-based editors which persist models as text files. In contrast, we propose a projectional editor that persists models natively as EMF models; the textual representation constitutes a projection of the underlying EMF model. Projectional editing does not only exclude syntactic errors; in addition, maintaining the underlying model persistently facilitates tool integration. The projectional editor is generic; it may be instantiated for different modeling languages by declarative definitions of their concrete syntax. So far, model editors for subsets of Java and ALF (Action Language for Foundational UML) have been built to demonstrate the feasibility of the generic approach. 1 INTRODUCTION diagram editors while EMF Parsley4 (Bettini, 2014) focuses on visualizations as trees, forms, or tables. While diagrams have been frequently used for The Eclipse Modeling Framework (EMF) (Stein- representing models, human-readable textual syntax berg et al., 2009) constitutes a popular ecosystem has become more and more popular recently. The for model-driven development. In the technological term “human-readable” excludes textual representa- space of EMF, a wide variety of tools for model- tions such as XML that have been designed for data driven development have been implemented. EMF exchange. Rather, human-readable syntax for mod- has established itself as a de facto standard for data els resembles the textual syntax of programming lan- models upon which many technologies and frame- guages. The trend towards human-readable syntax works are based, including server solutions, persis- may be exemplified by recent work on the Action Lan- tence frameworks, UI frameworks, and support for guage for Foundational UML (ALF) (OMG, 2017a). transformations1. While the UML standard (OMG, 2017b) originally Model editors which provide tool support for cre- defined only the abstract syntax of models and their ating, modifying, analyzing, and displaying mod- representation as diagrams, ALF provides a textual els, constitute key components of environments for language for both structural and behavioral model- model-driven development. Probably the first EMF- ing of a subset of UML (Foundational UML or fUML based editor that has been provided is the tree editor (OMG, 2018)) that features foundational execution belonging to the EMF core. Since then, a number of semantics. frameworks for building model editors have been de- Textual editors may be divided roughly into two veloped for different model representations. For ex- 2 3 categories. Syntax-based editors (cf. Figure 1) treat ample, frameworks such as GMF and Sirius (Ma- the text as the primary artifact that is stored persis- diot and Paganelli, 2015) support the development of tently. A command issued by the user results in the text being updated. Subsequently, the changes are 1https://www.eclipse.org/modeling/emf propagated to the model – i.e., to the abstract syntax 2https://www.eclipse.org/modeling/gmp/ 3https://www.eclipse.org/sirius/ 4https://www.eclipse.org/emf-parsley/index.html Modeler Modeler (1) Issues Command (1) Issues Command Syntax-Based Projectional Editor Editor (4) Updates Model (2) Updates Text (2) Updates Model (4) Updates Text (3) Propagates Changes (3) Propagates Changes Model Text Model Text (Transient) (Persistent) (Persistent) (Transient) Figure 1: Syntax-based editing. Figure 2: Projectional editing. tree that is represented by the plain text. The model be related by inter-model links, e.g., traceability is maintained only transiently, during an editing ses- links connecting models at different levels of ab- sion, and is used primarily for incremental syntactic straction or links between features and domain and semantic analysis. model elements in software product lines. Since In the technological space of EMF, among several text files do not provide for reliable identifiers of tools for building syntax-based editors, e.g., EMF- model elements, inter-model links may be easily Text5 (Heidenreich et al., 2011) for textual languages corrupted. that can be easily extended and integrated with other Projectional editors 6 (cf. Figure 2) invert the languages, the framework Xtext (Bettini, 2016) is syntax-based approach to model editing. Rather than the most prominent one. The editors are generated the text (concrete syntax), the model (abstract syn- from a grammar definition that refers to an underly- tax) is persisted. In the context of product line engi- ing metamodel. Grammar rules in Xtext are based neering, a great importance is attached to projectional on the Extended Backus-Naur Form (EBNF) (Yue, editors, e.g., the PEoPL approach (Behringer et al., 2014). Either the starting point is the grammar from 2017) combines different representations. Commands which the metamodel is generated (concrete syntax issued by the modeler affect the model rather than the first) or the grammar is specified for an existing meta- text. After the model has been updated, the changes model (abstract syntax first) which has been built us- are propagated to the text which is updated accord- ing any tool in the EMF context (e.g., the Ecore tree ingly in turn. For experienced users, projectional editor). The generated editor artifacts can be aug- 7 editors may feel less natural and comfortable than mented with Xtend classes describing the custom syntax-based editors (Volter¨ et al., 2014). On the scoping rules, validation constraints, hovering infor- other hand, projectional editors solve the problems mation, highlighting, etc. The (customized) editor mentioned above: plug-ins for the specific language may be used by ar- bitrary EMF-based projects. • A projectional editor guarantees syntactic cor- Syntax-based editors are flexible since they allow rectness by offering only commands that per- the modeler to issue arbitrary text-based commands. form correctness-preserving in-place model trans- For the same reason, they are easy to learn (usually, formations. For example, a command for insert- the modeler is familiar with the operation of text edi- ing some syntactic unit is allowed only at loca- tors). On the other hand, they suffer from the follow- tions where this unit is legal and ensures syntactic ing shortcomings: correctness of the inserted syntactic unit. • • There is a high risk of syntactic errors since the A projectional editor facilitates tool integration by modeler may type arbitrary text. This may be providing reliable means for identifying model el- problematic for beginners who are not familiar ements. While line numbers in text files are sub- uni- with the respective modeling language. ject to change, elements may be assigned versally unique identifiers (UUIDs) that are im- • Tool integration may be hampered by storing mutable. models as text files. For example, models may This paper fills a gap in the EMF tool landscape by 5https://marketplace.eclipse.org/content/emftext providing a generic projectional editor for EMF mod- 6https://www.eclipse.org/Xtext/ els that is distinguished by the following key proper- 7a Java dialect, see https://www.eclipse.org/xtend/ ties: • The projectional editor stores the abstract syntax for each type in a separate file – similar to defining of some model as an ordinary EMF model, en- Java classes. Furthermore, instead of specifying the abling integration with any EMF-based tool for concrete syntax similar to a grammar, each concept model transformations, code generation, etc. provides an additional text file to describe the nota- • The projectional editor is generic inasmuch as an tion of the respective element. For defining custom EMF model may be instantiated from an arbi- scoping, validation, building a type system, etc. also trary metamodel (defining the abstract syntax of a special textual notation is used instead of providing some modeling language) that provides univer- artifacts in a common general-purpose language. sally unique identifiers for objects. The rest of this paper is structured as follows: Sec- tion 2 provides an overview of our approach to pro- • So far, the projectional editor supports textual rep- jectional editing. Section 3 explains the functionality resentations. However, its underlying design is and the user interface of the projectional editor by out- extensible such that support for other representa- lining an exemplarily editing process within a sample tions (e.g., diagrams) may be added in the future. ALF editor. Section 4 describes its underlying soft- • Deviating from Figure 2, representations are per- ware architecture. Section 5 introduces the language sisted, as well – again as EMF models. This that is used for context-free syntax definitions while approach allows to persist
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-