mdenet / educationplatform

Eclipse Public License 2.0
2 stars 3 forks source link

Adding more than one Xtext editor breaks syntax highlighting #197

Open szschaler opened 3 months ago

szschaler commented 3 months ago

When adding more than one xtext editor in a generated Xtext activity, none of them get syntax highlighting or validation anymore. Eg, in the below, none of xtext-editor, xtext-editor-2, or xtext-editor-3 have syntax highlighting and only the first one has code completion and validation.

{
    "activities": [
        {
            "id": "xtext-validator",
            "title": "Define the model validator",
            "icon": "xtext",

            "tools": ["https://mdenet-ep.sites.er.kcl.ac.uk/tools/xtext/xtext_tool.json"],

            "panels": [
                {
                    "id": "hidden-panel-mm",
                    "name": "XMI text format",
                    "ref": "ecore",
                    "file": "uk.ac.kcl.inf.mdd.deployLang2/model/generated/DeployLang2.ecore"
                },
                {
                    "id": "panel-composite",
                    "name": "Language definition",
                    "ref": "composite",
                    "childPanels": [
                        {
                            "id": "panel-v",
                            "name": "Model validator",

                            "ref": "xtext-validator",

                            "file": "uk.ac.kcl.inf.mdd.deployLang2/src/uk/ac/kcl/inf/mdd/validation/DeployLang2Validator.xtend",

                            "buttons": [
                                {
                                    "id": "generate-editor-button",
                                    "hint": "Generate Xtext editor and model validator",
                                    "icon": "run",
                                    "actionfunction": "function-xtext"
                                },
                                {
                                    "ref": "help-button"
                                }
                            ],

                            "editorActivity": "xtext-use",
                            "editorPanel": "xtext-editor"
                        },
                        {
                            "id": "panel-mm-diagram",
                            "name": "Metamodel diagram",
                            "ref": "emfgraph"
                        }
                    ],

                    "buttons": [
                        {
                            "id": "gen-mm-diagram",
                            "hint": "Load metamodel diagram",
                            "icon": "diagram-generate",
                            "actionfunction": "function-emfatic2plantuml"
                        },
                        {
                            "id": "show-val-button",
                            "icon": "editor",
                            "internal": "toggle",
                            "targetPanel": "panel-v",
                            "hint": "Toggle validator code"
                        },
                        {
                            "id": "show-diagram-button",
                            "icon": "diagram",
                            "internal": "toggle",
                            "targetPanel": "panel-mm-diagram",
                            "hint": "Toggle metamodel diagram"
                        }
                    ]
                },
                {
                    "id": "hidden-panel-xtext",
                    "ref": "xtext-grammar",
                    "name": "Hidden grammar panel",
                    "file": "uk.ac.kcl.inf.mdd.deployLang2/src/uk/ac/kcl/inf/mdd/DeployLang2.xtext"
                },
                {
                    "id": "panel-console",
                    "name": "Console",
                    "ref": "console"
                }
            ],

            "layout": {
                "area": [
                    ["panel-composite"],
                    ["panel-console"]
                ]
            },

            "actions": [
                {
                    "source": "panel-v",
                    "sourceButton": "generate-editor-button",

                    "parameters": {
                        "languageName": "uk.ac.kcl.inf.mdd.deployLang2.DeployLang2",
                        "baseName": "uk.ac.kcl.inf.mdd.deployLang2",
                        "extension": "deploylang2",
                        "grammar": "hidden-panel-xtext",
                        "validator": "panel-v"
                    },

                    "output": "panel-console"
                },
                {
                    "source": "panel-composite",
                    "sourceButton": "gen-mm-diagram",

                    "parameters": {
                        "language": "generated",
                        "emfatic": "hidden-panel-mm"
                    },

                    "output": "panel-mm-diagram"
                }
            ]
        },
        {
            "id": "xtext-use",
            "title": "Use the code generator",
            "icon": "xtext",

            "tools": ["{{ID-xtext-editor}}/editor_tool.json", 
                      "https://mdenet-ep.sites.er.kcl.ac.uk/tools/emf/emf_tool.json",
                      "https://mdenet-ep.sites.er.kcl.ac.uk/tools/emfatic/emfatic_tool.json",
                      "https://mdenet-ep.sites.er.kcl.ac.uk/tools/epsilon/tools"],

            "panels": [
                {
                    "id": "xtext-editor",
                    "name": "Example deployment definition",
                    "ref": "xtext-editor",
                    "extension": "deploylang2",

                    "file": "example/test1.deploylang2",

                    "buttons": [
                        {
                            "ref": "to-diagram-button"
                        }
                    ]
                },
                {
                    "id": "panel-diagram",
                    "name": "Model diagram",
                    "ref": "emfgraph"
                },
                {
                    "id": "xtext-editor-2",
                    "name": "Example deployment definition",
                    "ref": "xtext-editor",
                    "extension": "deploylang2",

                    "file": "example/test2.deploylang2",

                    "buttons": [
                        {
                            "ref": "to-diagram-button"
                        }
                    ]
                },
                {
                    "id": "panel-diagram-2",
                    "name": "Model diagram",
                    "ref": "emfgraph"
                },
                {
                    "id": "xtext-editor-3",
                    "name": "Example deployment definition",
                    "ref": "xtext-editor",
                    "extension": "deploylang2",

                    "file": "example/test3.deploylang2",

                    "buttons": [
                        {
                            "ref": "to-diagram-button"
                        }
                    ]
                },
                {
                    "id": "panel-diagram-3",
                    "name": "Model diagram",
                    "ref": "emfgraph"
                }
            ],

            "layout": {
                "area": [
                    ["xtext-editor", "panel-diagram"],
                    ["xtext-editor-2", "panel-diagram-2"],
                    ["xtext-editor-3", "panel-diagram-3"]
                ]
            },

            "actions": [
                {
                    "source": "xtext-editor",
                    "sourceButton": "to-diagram-button",

                    "parameters": {
                        "input": "xtext-editor",
                        "language": "generated"
                    },

                    "output": "panel-diagram"
                },
                {
                    "source": "xtext-editor-2",
                    "sourceButton": "to-diagram-button",

                    "parameters": {
                        "input": "xtext-editor-2",
                        "language": "generated"
                    },

                    "output": "panel-diagram-2"
                },
                {
                    "source": "xtext-editor-3",
                    "sourceButton": "to-diagram-button",

                    "parameters": {
                        "input": "xtext-editor-3",
                        "language": "generated"
                    },

                    "output": "panel-diagram-3"
                }
            ]
        }
    ]
}
barnettwilliam commented 3 months ago

I don't expect multiple language editor panels per page to be supported based on the current implementation of XtextEditorPanel. Each XtextEditorPanel instantiates an Xtext ace editor that sets up a connection to the deployed editor and applies the highlighting, instead, only a single Xtext ace editor should be instantiated with a resource for each panel.