I've a set of concepts that represent types of entities Hrrr.
Sample concepts:
Loop
with children loopCount: IntegerProperty[1]
HttpRequest
with children url: StringProperty[1]
, hostName: StringProperty[1]
Both concepts extend AbstractTestElement
concept (it defines common properties like name, comment, etc).
I want Loop
and HttpRequest
to be generated to baseLanguage as follows:
Loop:
Loop e = new Loop();
e.setProperty(new IntegerProperty("loopCount", node.loopCount));
HttpRequest:
HttpRequest e = new HttpRequest();
e.setProperty(new StringProperty("url", node.url));
e.setProperty(new IntegerProperty("host", node.hostName));
What I want is to have some common generator template that covers this common logic for setProperty
so it is not repeated for different kinds of test elements.
Well, there are properties that require specific-to-test-element treatment, however there are often cases when properties are one-to-one translated, thus
Here's the question: how can I attach metadata to the Loop/HttpRequest concept configuration? What is MPS-idiomatic way of doing that?
1) While I could use "names of properties" as names put into the new XXXProperty
, however ideally I would use HttpRequest.HOST_PROPERTY_NAME
kind of references, thus "names of properties" is not sufficient.
2) I might probably invent annotations and annotate properties of my concepts, it looks like MPS itself does not use that approach.
3) (ab)using concept's behaviors to return <quotation new StringProperty("url", node.url) >
looks even more awkward.