[TYPO3-mvc] Re: Getter/Setter generator for .jEdit
Nils Blattner
nb at cabag.ch
Fri Feb 19 14:21:39 CET 2010
Note: You may just ignore this if you are not using .jEdit
As I said in my feedback post, I couldn't use Eclipse. But writing
getters and setters without macro's is rather boring and drab.
So I made a regex + bean shell that does the trick:
When you have a property of the type
/**
* The First Name
*
* @var string
*/
protected $firstName = '';
it will create a string after each property.
Sadly I had some problems with new lines in bean shell. So i just made
it output {nl} which has to be replaced with a new line and voilà.
Regex: (\/\*\*\s*\*\s)([^\n]+)(\s*\*\s+\*\s\@var
)([^\s]+)([^\/]*\*\/\s+protected \$)([^\s]+)([^;]*;)
-> _2 == desc, _4 == type, _6 == name
BeanShell:
_1+_2+_3+_4+_5+_6+_7+"{nl}{nl}"+" /**{nl} * Sets
"+_2.substring(0,1).toUpperCase()+_2.substring(1)+"{nl} *{nl} * @param
"+_4+" $"+_6+" "+_2+"{nl} * @return void{nl} */{nl} public function
set"+_6.substring(0,1).toUpperCase()+_6.substring(1)+"($"+_6+") {{nl}
$this->"+_6+" = $"+_6+";{nl} }{nl}{nl} /**{nl} * Returns
"+_2.substring(0,1).toUpperCase()+_2.substring(1)+"{nl} *{nl} *
@return "+_4+" "+_2+"{nl} */{nl} public function
get"+_6.substring(0,1).toUpperCase()+_6.substring(1)+"() {{nl} return
$this->"+_6+";{nl} }"
After that: replace all {nl} with new lines
More information about the TYPO3-project-typo3v4mvc
mailing list