Creating a String property programatically
Hi,
I'm looking to add a string property to a concept programatically. Here is my code so far:
node<PropertyDeclaration> newProperty = new node<PropertyDeclaration>();
newProperty.name = propName;
newProperty.dataType.set(concept/StringType/.asNode);
currNode.propertyDeclaration.add(newProperty);
The dataType of the property should not be StringType, but I'm not sure what it should be. Perhaps a StringLiteral? Some sort of PrimitiveDataTypeDeclaration?
Thank you for your help.
Please sign in to leave a comment.
The datatype should be set to "node/string/", where "string" is the name of a PrimitiveDataTypeDeclaration node declared in j.m.lang.core.
Vaclav
Thanks for the quick reply.
This works very well, thank you. But I'm concerned that the node component of node/string/ has a strike-through. Is this deprecated?
Yes, it is, but there is no better alternative available at the moment. We'll most likely keep the node/.../ syntax in the future and just implement it slightly differently. So it is quite safe to use the expression in your code.