Skip to content

MPS plugin for generating textGen definitions derived from editor definitions, so that the text generated by textGen is the same as the one rendered on the screen by the editor

License

Notifications You must be signed in to change notification settings

Fumapps/textGenGen

 
 

Repository files navigation

Fork by Fumapps

This fork is an extension of the TextGenGen MPS plugin. It mainly extends it by:

  • unit tests: several automated tests, which are used to fix several spacing issues
  • generator-based contents check: a (light) diff mechanism, which tries to detect if TextGen nodes have not really changed
  • github actions: contains GitHub actions workflows for integration or release builds
  • GrammarCells: support for generating mps-extensino grammarcells (without adding a dependency on it)
  • single node TextGenGen: support to generate TextGenGen only on a single concept node

TextGenGen

TextGenGen is an MPS plugin for generation of TextGen definitions derived from Editor definitions, so that the text generated by TextGen is the same as the one rendered on the screen by the Editor.

Getting started

This version/fork of the plugin is not on the JetBrains MPS Marketplace. A zip with the built plugin is supplied with every release on the github releases page.

However, if you want to make any modification to the plugin, you could find useful these guides:

To build the plugin:

  • Define the TEXTGENGEN_HOME path variable
    • Go to File > Settings > Apppereance & Behavior > Path Variables
    • Add a new variable with the name TEXTGENGEN_HOME and the value of the path to the top-most directory of the TextGenGen project (e.g. C:\Users\yourName\MPSProjects\textGenGen)
  • Open the TextGenGen project in MPS
  • Expand the TextGeGEn.build item in the project explorer
  • Right-click the TextGenGen item with a spider icon
  • Trigger Run TextGenGen
  • The plugin ZIP file is located in the directory hierarchy of the project (build/artifacts/TextGenGen)

To install the plugin:

  • Open MPS
  • Go to File > Settings > Plugins > Install plugin from disk... and locate the ZIP archive
  • After a MPS restart, the plugin should be loaded

To use the plugin:

For the primary function of the plugin:

  • Make sure you do not have any local work in the TextGen Aspect of your language, as it will be overwritten
  • Right click your language in the MPS logical view and select Generate TextGen
  • The TextGen Aspect of your language will be generated based on the implemented Editor Aspect
  • Possibilities to customize the behavior:
    • Editor cells that should be ignored when generating the TextGen Aspect can be marked as such by setting their cell id to ignoreTextGenGen

For the second function

  • Right click any model (i.e. model in a Solution or Aspect (or other kind of model) in a Language) and select Save as Text.
  • You will be prompted for the filesystem location and file extension to use.
  • After entering the data and pressing Ok, the plugin will export a textual representation of all nodes in the model as they are rendered on the screen.

Release log

For changes on this fork please look at the github releases page.

Changes brought by version 1.1, 11/2019:

  • Fix spacing between elements of a ref-node list
  • Add support for editor cells representing AST references
  • Implementation of enumeration support
  • Refactoring of deprecated parts

Major changes brought by version 1.0, 9/2019:

  • Generation of TextGen removes the previously generated TextGen and does not ask for a prefix anymore
  • Newly supported aspects of the Editor (so that the generated TextGen respects them):
    • Show if at an Editor cell
    • Editor components (the #alias# component too)
    • Empty cell models at a child reference list and/or a child reference
  • Improved implementation of indentation and spacing generation
  • Refactoring: redesign of the plugin core to a more pure form, documentation of the code

Version 0.4

  • Support of simple Editor constructs
  • The design is basically prepared to be extended by support of more complex Editor constructs

Development notes

Design overview

Plugin Core

The entry-point object of the plugin core is EditorToTextGenConvertor, which provides generation of TextGen for a given Editor. This object uses the EditorCellToTextGenConvertor object to generate TextGen chunks corresponding to individual Editor cells. This object uses the Gang-of-Four Builder pattern: it delegates generation of smaller, general chunks of the TextGen to the TextGenBuilder object.

TextGenBuilder is intended to be Editor-independent so it should not contain any knowledge of the Editor structure and should understand the TextGen structure only.

The utils virtual package contains some helper classes:

  • CustomStyleContainer: A wrapper for styling from Editor cells
  • Value, Constant, Query: Wrappers for (run-time evaluated) conditions
  • NameProvider: A generator of unique identifiers
  • StatementsBuffer: A holder for TextGen statements which executes some basic optimizations of the inserted statements
  • Utils: General utility methods

About

MPS plugin for generating textGen definitions derived from editor definitions, so that the text generated by textGen is the same as the one rendered on the screen by the editor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JetBrains MPS 99.8%
  • Java 0.2%