Extending Editor language

Hello,

  I want to extend the editor language to define new types of cells. Is there any specification for the editor language or can I get a tutorial for how to extend it?

Kindly regards,

Eman Negm

 

1
2 comments

Dear E Negm,

Currently, there is no tutorial, but there is the page you could find useful: https://confluence.jetbrains.com/display/MPSD20171/Editor+language+generation+API

1

I'd like to join this issue. I want to create a cell type with child elements (more precise: one child that could be a collection). I took the framecell provided by the mbeddr-framework as example but I'm not even able to recreate it. I guess that the changes in MPS 2017.1 are the reason. I read the page you linked to your answer but it would be great to see a working example.

Here is what I have done:

  • I created a concept "SectionCell" (as in mbeddr CellModel_FrameCell) which extends EditorCellModel. This concept has a child "child" of EditorCellModel.
  • The editor just lists a constant and the child in a vertical collection
  • I created two BaseLanguage classes "SectionCell" extending EditorCell_Collection (as in meddr FrameCell) and "SectionCellLayout" extending AbstractCellLayout
      
    In SectionCellLayout the doLayout() method is overwritten to move the child element of a SectionCell
       In SectionCell the paintDecorations() method is overwritten to draw a frame around the child element
  • I copied the generator files from mbeddr's framecell
  • I built my SectionCellLanguage
  • I can insert a SectionCell in the Editor but the Editor build fails due to errors in the generation

This is where I got stuck:

I tried to find out the reasons for each statement in the generatorfiles. This is how they look like

 

FrameCell mapping configuration

As I understand, the first fragment with the copy-src macro generates the createCollection/Constant() functions for the SectionCell's child element (which is mapped to the macro inside the inspector view). The second fragment loads a template (see below) and the third fragment with the CommonMethods template seems to generate nothing.

 

reduce_CellModel_FrameCell

When I run the code without any customizations (except replacing the FrameCell language references with SectionCell language references) I get an error on the generation of the second last line of the callFacrotyMethod fragment (editorCell.addEditorCell()): The parameter reference is broken - in the generated code it shows editorCell.addEditorCell(<no_method>()).

The mapping label cellFactoryMethod reveals to me that this template is not adapted to the new Editor language generation API. I replaced it with cellFactory.factoryMethod which somehow destroyed the generation of the unlabled fragment: the generated function first called the function generated by the first fragment. Now the reference is broken.

I edited the generator files a lot but without success; thus I hope for your guidence in this matter. It would be great if I got this somehow working. Still, I would prefer to understand how a custom cell type is meant to be generated with the Editor Language Generation API.

Regards,

Aaron

1

Please sign in to leave a comment.