Behavior works differently when packed into Idea plugin

In my language I have a behavior that provides names for generated classes.
public string getBeanName() { 
  this.name + "TLBean"; 
}


That works fine when used in MPS. When packed into Idea plugin "this.name" returns null.

What's wrong with this code? Or behavior are not supported in Idea?
0
4 comments
After some investigation I found that this happens only if in Idea I have two models, one of which is referencing another.
Dereferencing a node from another model leads to strange results - node.name returns null.
0
Avatar
Permanently deleted user
Does it happen only in the Generator? (You can try to add 'readonly model access' cell into the Inspector of your node to check this).
If so, the reason is probably that we use out-of-process, ANT-based backend, which ignores your plugin.xml and loads languages from the 'languages' folder of your plug-in (by convention). The behavior won't work if its language is not found.
0
Does it happen only in the Generator? (You can try to add 'readonly model access' cell into the Inspector of your node to check this).

it happens in generator only. I changed editor for reference concept so it defines "get" accessor as a call to behavior in question. Editor works fine in both MPS and Idea.
0
Okay, I narrowed down my project to just one concept(TransportBean) and a reference to it(TransportBeanReference).
Concept has only one child - reference, and generates to a class with string field, which value is defined as property macro:
property macro
comment : <none>value : (node, templateValue, genContext, operationContext)->string {
  ifInstanceOf (node.ref is TransportBeanReference tpr) {
    ifInstanceOf (tpr.transportBean is TransportBean tb) {
      return "!" + tb.name;
    }
    return tpr.transportBean.name;
  }
  "Fail";
}


Cross-model references works fine in MPS. In Idea - empty string.

After adding some debug statements, I found that following code gets executed, meaning that imported models are no present at generation time.
if (node.ref.transportBean.isNull) { return "tb.null"; }
0

Please sign in to leave a comment.