How to: Programmatically disable/enable language generators?

Hi,

I'd like to programmatically disable/enable language generators in MPS.

The reason for this is that we have multiple RCPs for different stakeholders that work on the same models in production, but aren't interested in all generated artifacts.

My goal is to individually disable/enable generators for stakeholders, so that they just generate the artifacts that they need and don't waste computation time on unnecessary artifacts.

Does anyone know how to do this? I could do it with preconditions for each root mapping rule, but I think there might be a more elegant solution. :)

 

Best regards

Tobi

0
5 comments

you could use devkits for the models
in these devkits the plans decide which generators are invoked
by introducing properties that the generators lookup before generating they would know if they would be invoked

0
Avatar
Permanently deleted user

+1, generation plans were designed to use different set of generators for a model. In MPS,tThere's no support to switch plans on the fly/on demand, this functionality have to be created by language designer (i.e. whether it's distribution-controlled, or a dedicated action for user to invoke, or a specific 'perspective/workspace/role').

0

I think DevKits would not work in this case, because we have multiple root nodes in one model. Each root node is important to different stakeholders:

modelA:

  • Node1 (for stakeholder of domain X)
  • Node2 (for stakeholder of domain X, Y)
  • Node3 (for stakeholder of domain Y)

This means that each RCP has to have all languages of domain X and Y deployed to work with "modelA". If I use DevKits to selectively enable/disable generators, I have to split my model for the X, Y and XY domain and import a specific DevKit for each of them.

I guess implementing some approach to manually switch plans is the way to go in this case.

 

 

0

Could You provide a sample project for your use case on GitHub? I would be happy to look for an easy solution.

0

Sorry that I did not answer to your question  (until yet).

I solved this problem with:

  • Custom options under "File" => "Settings" => "Other Settings" => "Generator". These settings contain a view with a list of checkboxes. Each checkbox represents a single generator. If the check box is checked, the generator option is activated and deactivated otherwise. We use the following API to set runtime properties of MPS: PropertiesComponent.getInstance().setValue(propertiesKey, value, defaultValue);
  • Each of my generator mapping scripts implement the "isApplicable" condition. The condition just checks if the setting for this generator is activated. We use the following API to check the setting of a generator: PropertiesComponent.getInstance().getBoolean(propertiesKey, defaultValue)
  • I activate/deactivate generators via a custom "config/options/other.xml" config file. It depends on the stakeholder which generators are activated/deactivated by default => I just deploy a different "other.xml" file.
0

Please sign in to leave a comment.