Using generator to create concept instances

Dear sirs

Is there any way to create new instances of concepts, inside a solution, using the generator of one of the languages referenced in that solution?

Currently I'm using a MPS plugin to programmatically create new concept instances and it works fine

  Iterable<? extends SModule> smdAllL = ProjectManager.getInstance().getOpenedProjects().get(0).getModules();
  foreach modCurrentL in smdAllL {
    if (modCurrentL.getModuleName().equalsIgnoreCase("my module name")) {
      Iterable<SModel> mdlAllL = modCurrentL.getModels();
      foreach mdlCurrentL in mdlAllL {
        if (mdlCurrentL.getModelName().equalsIgnoreCase("my module model name")) {
          mdlCurrentL.add root(new node<my concept>())

But I wonder if there is a better and more natural way, specifically through the use of the generator of a language that I refer to in the solution.

Many thanks

Evaristo Figueiredo

1 comment

Hi, Evaristo,

The answer depends on why do you need those nodes. If you need them in a source model, then the answer is no, generator does not change the source model. If you need them to further generate some code, the answer is yes, generator can create new nodes "from nowhere" during the generation




Please sign in to leave a comment.