PropertyMacro for a part of a method name?
I played a bit around with the calculator tutorial and wanted to add methods which print out the strings from the input fields (e.g. width, height, and deepth for MyCalc). So I added a printWidth method, looped it with a loop macro and printed out the value with a property macro. This works fine, but I wanted to be generated three methods with a same prefix and a generated suffix: printWidth, printHeight, and printDeepth. If I mark the Width in printWidth and select property macro via Alt-Enter, the whole function name is marked and made to a property macro automatically. Is there no possibility to generate method names with prefix and suffix and one of them generated? This would also be useful for unit tests: public void testXXX()...
Jens
Please sign in to leave a comment.
Hi Jens, you can only wrap whole property value into a property macro (i.e. whole method name). But you can implement any strategy of generation of the propery value in property-macro's 'value' function like:
{
... computing the name suffix ...
return "print" + suffix;
}
Works fine. Crazy what you can do with MPS.