Community
Participate
Working Groups
Support for simple expressions involving template variable would be nice. There is one particular use for expressions that I am looking for the most: given a property name, create the method name for a setter or a getter. To do this correct in all cases, knowledge of types would be necessary. For most cases, capitalization of the first character of a variable is enough. I use templates for repetitive code that involves properties, for example code to fire PropertyChangeEvents in setter methods. I would be happy with a special-purpose modification to allow upper/lowercasing, but perhaps a more generic approach involving functions and expressions is possible? Plugins could add functions to a library. I have no idea how complex this would be, but I would like to offer this as a suggestion for enhancement.
If I understand this correctly, I think you are looking for something that will take a Template that looks like this: ================= private ${type} ${field}; public ${type} get${property}() { return this.${field}; } public void set${property}(${type} value) { this.${field} = value; } ================= and instead of typing three separate variables, I would type two: the ${type} and ${property}. Then, the template would reformat the ${property} as either camelCasing or PascalCasing, depending on some feature of the variable. For example, I could have a template like this: ================= private ${type} ${property:camelCasing}; public ${type} get${property:PascalCasing}() { return this.${property:camelCasing}; } public void set${property:PascalCasing}(${type} value) { this.${property:camelCasing} = value; } ================= If this is what you would like, I absolutely agree. I have a lot of templates that I use frequently where I have to type the same thing twice to match both casings.
Yes, that is exactly what I would like. (BTW: wow, that's a blast from the past. 2005! :-) ) But I believe other people may want different functions on the field name, and if this were implemented, it probably wouldn't be much harder to make the functions like 'camelCase' or 'PascalCase' extensible through a plugin.