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.

 

1
3 comments

The datatype should be set to "node/string/", where "string" is the name of a PrimitiveDataTypeDeclaration node declared in j.m.lang.core.

Vaclav

 

0

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?

0

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.

0

Please sign in to leave a comment.