Textual editor

This section relates on the use of EMFText or XText technologies for the development of a textual editor for block libraries declaration. We encourage the reader to consult the documentation provided on these web sites and related materials in order to use these two technologies.

The important part of this work is to manage to have a constraints writing capability embedded in the editor. We want to be able, in the same textual editor, to write a BlockLibrary specification and constraints.

Embedding OCL constraints in a textual editor has been experimented by Heidenreich et al with EMFText technology. A reference to this work is given in the Related works page.

The formal block specification editor

An Eclipse plugin is provided in the plugin folder allowing its users to write block specifications. There are two parts in this editor:

  • Plugins holding the EMF editors related to the BlockLibrary metamodel

    • org.geneauto.emf.blocklibrary._1.0.0.*.jar
    • org.geneauto.emf.blocklibrary.edit_1.0.0.*.jar
    • org.geneauto.emf.blocklibrary.editor_1.0.0.*.jar
  • Plugins holding the XText editor using the previous plugins

    • org.geneauto.xtext.blocklibrary_1.0.0.*.jar
    • org.geneauto.xtext.blocklibrary.ui_1.0.0.*.jar

General points

The XText editor is based on the BlockLibrary Meta-model. Based on this meta-model, a grammar has been written. It can be found here or in org.geneauto.xtext.blocklibrary/src/org/geneauto/xtext/Blocklibrary.xtext.

Notational conventions

Keywords are all lower case instaed of camel case
(Similarly to e.g. Java and Ada (GNAT))

No quotes around declared identifiers

Single inheritance doesn’t need anyof/allof

In the specification we assume that there exists only one block instance of the current type. This is the instance returned by the blockInstance() function. All metamodel relations between the specification and implementation elements refer only to that block instance or its components. For example:

  • parameterImpl is considered a one-to-one relation and we write parameterImpl instead of parameterImpl->first()
  • portImpl is still a one-to-many relation, since there can be several ports in one block instance that implement one PortGroup

TODO DISCUSS: Should we and how to specify this porperty on the metamodel? Is it neccessary to have parameterImpl as one-to-many relation? It is a bit different for blockImpl, since there can be an application for coupling a whole system model (block instances) and block library model (specs). But probably not for the components of the block instance-spec. This last operation would alwyas be performed for one block instance? Note, that we can still have multiple Parameter elements referring to one ParameterType.

ParameterTypes that map to virtual PortGroups are specified as PortGroups. Implictly there is also a corresponding ParameterType in the model. The PortGroup definition has following additions:

  • There is a keyword virtual before the PortGroup’s name
  • The name of the ParameterType is specified in the implementedBy reference

Embedded languages

Details on the specification of the embedded used languages can be found here:

Additional modifications of the editor

Checking OCL constraints in the XText editor

The validation part of the XText editor plugin has been extended in order to include OCL constraints checking while using the editor. This is done in the org.geneauto.xtext.blocklibrary/src/org.geneauto.xtext.validation.BlockLibraryValidator.java file.

Constraints that are checked during this process are the ones specified in this OCL file. Also available in org.geneauto.emf.blocklibrary/constraints/BlockLibrary_Main.ocl

Documentation attribute highlighting

An extension of the editor is used to manage documentation fields:

Two new classes are used for syntax highlighting:

  • org.geneauto.xtext.blocklibrary.ui/src/org/geneauto/xtext/ui/BlockLibraryHighlightingConfiguration.java
  • org.geneauto.xtext.blocklibrary.ui/src/org/geneauto/xtext/ui/BlockLibrarySemanticHightlightingCalculator.java

A class has been, developed to add a folding capability on documentation:

  • org.geneauto.xtext.blocklibrary.ui/src/org/geneauto/xtext/ui/BlockLibraryFoldingRegionProvider.java

These classes are referenced in the UiModule to be used in the editor:

  • org.geneauto.xtext.blocklibrary.ui/src/org/geneauto/xtext/ui/BlocklibraryUiModule.java

Templates

Additional templates are provided to ease the BlockLibrary specification writing:

  • org.geneauto.xtext.blocklibrary.ui/src/org/geneauto/xtext/ui/BlockLibraryTemplatesProvider.java

This class must also be referenced in the UiModule.

Note

  • Two modifications have been done on the metamodel in order to simplify this first prototyping:

    • We avoid the usage of Expressions by replacing the dimensions reference of the datatypes.TArray metaclass by an EInt attribute using the same name.
    • A name: EString attribute has been added to datatypes.DataType