|
4 | 4 | " Maintainer: Pierrick Charron <pierrick@adoy.net> |
5 | 5 | " URL: https://github.com/adoy/vim-php-refactoring-toolbox |
6 | 6 | " License: MIT |
7 | | -" Version: 1.0.1 |
| 7 | +" Version: 1.0.2 |
8 | 8 | " |
9 | 9 |
|
10 | 10 | " Config {{{ |
@@ -353,21 +353,30 @@ endfunction |
353 | 353 | " }}} |
354 | 354 |
|
355 | 355 | function! s:PhpInsertProperty(name, visibility) " {{{ |
356 | | - if search(s:php_regex_member_line, 'beW') > 0 |
357 | | - let l:insertLine = line('.')+1 |
358 | | - elseif search(s:php_regex_const_line, 'beW') > 0 |
359 | | - let l:insertLine = line('.')+1 |
360 | | - elseif search(s:php_regex_class_line, 'beW') > 0 |
361 | | - call search('{', 'W') |
362 | | - let l:insertLine = line('.') |
363 | | - else |
364 | | - let l:insertLine = line('.') |
365 | | - endif |
366 | | - call append(l:insertLine, '/**') |
367 | | - call append(l:insertLine+1, '* @var mixed') |
368 | | - call append(l:insertLine+2, '*/') |
369 | | - call append(l:insertLine+3, a:visibility . " $" . a:name . ';') |
370 | | - call append(l:insertLine+4, "") |
| 356 | + let l:regex = '\%(' . join([s:php_regex_member_line, s:php_regex_const_line, s:php_regex_class_line], '\)\|\(') .'\)' |
| 357 | + if search(l:regex, 'beW') > 0 |
| 358 | + let l:line = getbufline("%", line('.'))[0] |
| 359 | + if match(l:line, s:php_regex_class_line) > -1 |
| 360 | + call search('{', 'W') |
| 361 | + call append(line('.'), "") |
| 362 | + let l:insertLine = line('.') |
| 363 | + else |
| 364 | + call append(line('.'), "") |
| 365 | + let l:insertLine = line('.') + 1 |
| 366 | + endif |
| 367 | + else |
| 368 | + call append(line('.'), "") |
| 369 | + let l:insertLine = line('.') |
| 370 | + endif |
| 371 | + call s:PhpInsertPropertyExtended(a:name, a:visibility, l:insertLine) |
| 372 | +endfunction |
| 373 | +" }}} |
| 374 | + |
| 375 | +function! s:PhpInsertPropertyExtended(name, visibility, insertLine) " {{{ |
| 376 | + call append(a:insertLine, '/**') |
| 377 | + call append(a:insertLine+1, '* @var mixed') |
| 378 | + call append(a:insertLine+2, '*/') |
| 379 | + call append(a:insertLine+3, a:visibility . " $" . a:name . ';') |
371 | 380 | normal j=5= |
372 | 381 | endfunction |
373 | 382 | " }}} |
|
0 commit comments