Property Macros in the Generator

Hi,

I am having some trouble trying to use property macros in the generator. I am trying to generate classes, so my target concept is ClassConcept. I want to make the class static based on some configuration. "nonStatic" is the property (of Classifier, a super concept of ClassConcept) that I need to set based on my configuration.

The problem is that I cannot set "nonStatic" in the generator. I tried the following ways, without success:

- I made my ClassConcept target in the template fragment static; clicked on "static" and tried to use intentions to add a new property macro. However, I could never get to "add new property macro". Of course, if I add a node macro, it will be for the whole node, and that's not what I need.

- I was able to add a property macro for "abstractClass" and "isFinal". That's because ClassConcept adds these two properties to Classifier and displays them in the Inspector. The inspector allows me to add a property macro by right clicking and going to the intentions menu (note that Alt-Enter won't let me add property macros). However, nonStatic is a property of Classifier, which ClassConcept does not expose in the inspector.

- I tried to open the ClassConcept node in the Node Explorer. There I could see that the other property macros were appended to the node. However, the Node Explorer does not allow for manipulating the model, only exploring it. It would be great if I could do whatever I want with the nodes there, like copying and modifying. I know this could break the model, but if you "know what you are doing..."

So, is this a bug which is not letting me add the property macro or should I do this in some other way?

Cheers,

Thiago

2 comments
Comment actions Permalink

Just to register my current workaround for this issue.

When I cannot create a property macro in the template, I create a node macro with MAP_SRC and set the appropriate properties in its "post-processing" function. It's ugly, but it works...

Cheers,

Thiago

0
Comment actions Permalink

Hello!

Looks like MAP_SRC is proper way to handle this situation right now. In addition I can propose creating two different template fragments - one with static class, another one with normal class inside and choose proper one from generator using condition.

BTW, I'm going to add "static" property to ClassConcept inspector now. ;-)

0

Please sign in to leave a comment.