JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
83 stars 51 forks source link

[Breaking] Extend grammar.wrap to check constraints properly #664

Closed HeikoBecker closed 1 year ago

HeikoBecker commented 1 year ago

Previously, if concept A contained concept B with an editor defined with grammar.rule with a grammar.wrap for B, constraints from A limiting occurrences of B were not taken into account when building the completion menu items.

This PR fixes this issue.

The PR is a breaking change because it alters completion menus for all concepts that fall under the above description.

Fixes #641.

HeikoBecker commented 1 year ago

Nice work! Without tests although, this change looks risky. The code itselfs looks good to me. Can you create an editor test that checks the code completion menu for each entry for some different constraints? An example from a different test to get the content of the code completion menu:

invoke action -> Backspace
....
SubstituteInfo si = (editor component.getSelectedCell()).getSubstituteInfo();
list<SubstituteAction> actions = si.getMatchingActions("", false);
assert actions.size == 4;
assert actions.any({ it => it.getMatchingText().equals("something"); });

Thanks for the tip! I have added tests for the canBeAncestor and canBeParent constraints in the latest commit.

markusvoelter commented 1 year ago

Cool!