Henshin and EMF Refactor



The implementation of refactoring Pre-condition is based on Henshin (v.0.7.0) and EMF Refactor (v.0.5.0). Henshin is a language and associated tool set for in-place transformations of models that are based on the Eclipse Modeling Framework (EMF). Henshin itself is based on graph transformation concepts and uses pattern-based rules that can be structured into nested transformation units with well-defined operational semantics (see here). EMF Refactor supports specification and application of refactorings wrt. EMF based models (see proceedings on here). Since the application module of EMF Refactor uses the Eclipse Language Toolkit (LTK) technology, a refactoring requires up to three parts. The parts of a refactoring specification reflect a primary application check for a selected refactoring without input parameters, a second one with parameters and the proper refactoring execution. Currently, EMF Refactor provides concrete refactoring specifications implemented in Java respectively Henshin transformations.

PIC 1

Figure 1: Part of the Henshin meta model

Figure 1 shows a small part of the Henshin meta model consisting of concepts used during refactoring implementation. A transformation rule consists of left and right-hand side graphs (respectively LHS and RHS) which describe model patterns by their underlying (graph) structure. Nodes refer to EClass objects while edges refer ro EReferences between objects via references called tyoe (not shown in Figure 1). These type references are used as explicit typing. Mappings between LHS and RHS can be defined based on nodes. Edge mappings are implicitly given if both, their source and target nodes are mapped. To conveniently determine where a specified rule should be applied, application conditions can be defined, either as positive application conditions (PACs) or negative application conditions (NACs). Graphs can be annotated with application conditions using a Formula that is either a logical expression (not shown in Figure 1) or a Nested Condition which is an extension of the original LHS graph structure. A rule can be applied to a host graph if all its application conditions are fulfilled.

The Hensin model supports a special kind of transformation units, called Amalgamation Units, which are useful to specify forall operations on recurring model patterns. An amalgamation unit contains an interaction scheme consisting of one rule which acts as a kernel rule and multiple rules which act as multi rules. The effect is that the modification defined in the kernel rule is applied only once while modifications defined in the multi rules are applied a certain number of times depending on the number of matches. A detailed presentation of amalgamation concepts can be found here.

 

05.07.2012