Generators priority with `mps.lang.editor` when implementing custom CellModel

Hi!

I want to implement custom `CellModel` to use in my language's editor. So I created additional language `myLanguage.util` where I have created new concept `CellModel_DynamicList`. I've used `CellModel_RefNodeList` as example, so my concept:

1. Extends `CellModel_ListWithRole`
2. Declares template `reduce_CellModel_DynamicList` (which uses `cellFactoryMethod` mapping label, and produces an instance factory method for `EditorCell`)
3. Declares template `reduce_DynamicList_ListHandler` (which uses `nodeListHandler` mapping label, and produces private static class that extends `RefNodeListHandler`)

On this picture you can see that its reduction remplate is almost a copy of the template for `CellModel_RefNodeList`.
This reduction is the only one declared in the mapping configuration `editor_ext`, which is placed in my `myLanguage.util` language.
So I want for it to be generated equally with the `mps.lang.editor` templates.

In my language I already have created a cell of this custom type, and it looks like this:

But when I try to generate this editor, I managed to get three unworking possible results:

1. If I set generators priority: `myLanguage.util/main.editor_ext = jetbrains.mps.lang.editor/`

I get error messages:

```
Conflicting mapping priority rules encountered:
Coherent configurations with different 'top priority' setting: [myLanguage.util/:myLanguage.util.generator.template.main.editor_ext] strictly_together [jetbrains.mps.lang.editor/:*]
```

2. If I set generators priority: `myLanguage.util/main.editor_ext >= jetbrains.mps.lang.editor/`

I get error messages:

```
Conflicting mapping priority rules encountered: Configuration with lower priority blocks high-priority configuration: [myLanguage.util/:myLanguage.util.generator.template.main.editor_ext] after_or_together [jetbrains.mps.lang.editor/:*]
```

3. If I set generators priority: `myLanguage.util/main.editor_ext <= jetbrains.mps.lang.editor/`

I get errors:

```
broken reference 'baseMethodDeclaration' in [operation] InstanceMethodCallOperation null[3044460634876100567] in myLanguage.editor@20_0 (target model is null)
-- -- was input node: [operation] InstanceMethodCallOperation null[3044460634876100567] in myLanguage.editor@20_0
broken reference 'baseMethodDeclaration' in [operation] InstanceMethodCallOperation null[3044460634876100578] in myLanguage.editor@20_0 (target model is null)
-- -- was input node: [operation] InstanceMethodCallOperation null[3044460634876100578] in myLanguage.editor@20_0
```
And these errors are the interesting ones, cuz as you can see on the previous picture my editor page contains an `indent collection` with two child elements: a constant cell, and my custom dynamic list cell.

Errors point to this transient model page:

As you can see - it contains private instance method `createDynamicList_` and private static class `DynamicListHandler_`, and both of them are produced by my custom cell model.

Method `createDynamicList_` properly references static class thru `nodeListHandler` mapping label.

But `createCollection_` method indicates two errors:

1. It tries to call method `createDynamicList_` twice, even though there's only one cell node of this type in the editor.

2. It fails to call method `createDynamicList_`, even thou by default it uses `template_CreateCellExpression` (from `mps.lang.editor`) which uses mapping label `cellFactoryMethod` to generate proper factory method call, and reduction of my cell model DOES use the same mapping label to produce instance factory method:

I am trying to find a solution for a day now, but it seems I just don't get it. My generators priority looks like this:

What is the proper way to configure generators priority in such a case?

Or is there another way to make it work?

Greatest thanks in advance!

1 comment
Official comment

Could you please check top-priority group setting of your exitor_ext mapping configuration? It looks you've got 'true' there, and that's why errors 1 and 2 (you can run top-priority configs only before configs with low aka regular priority, and that's the reason why third approach worked). If it's 'true', set it back to 'false' and try 'together with lang.editor' (1) again.

Please sign in to leave a comment.