|
45 | 45 | if !exists('g:vim_php_refactoring_default_method_visibility') |
46 | 46 | let g:vim_php_refactoring_default_method_visibility = 'private' |
47 | 47 | endif |
| 48 | + |
| 49 | +if !exists('g:vim_php_refactoring_make_setter_fluent') |
| 50 | + let g:vim_php_refactoring_make_setter_fluent = 0 |
| 51 | +endif |
48 | 52 | " }}} |
49 | 53 |
|
50 | 54 | " Refactoring mapping {{{ |
@@ -90,6 +94,10 @@ let s:php_regex_fqcn = '[\\_A-Za-z0-9]*' |
90 | 94 | let s:php_regex_cn = '[_A-Za-z0-9]\+' |
91 | 95 | " }}} |
92 | 96 |
|
| 97 | +" Fluent {{{ |
| 98 | +let s:php_fluent_this = "normal! jo\<CR>return $this;" |
| 99 | +" }}} |
| 100 | + |
93 | 101 | function! PhpDocAll() " {{{ |
94 | 102 | if exists("*" . g:vim_php_refactoring_phpdoc) == 0 |
95 | 103 | call s:PhpEchoError(g:vim_php_refactoring_phpdoc . '() vim function doesn''t exists.') |
@@ -128,6 +136,9 @@ function! PhpCreateSettersAndGetters() " {{{ |
128 | 136 | endif |
129 | 137 | if search(s:php_regex_func_line . "set" . l:camelCaseName . '\>', 'n') == 0 |
130 | 138 | call s:PhpInsertMethod("public", "set" . l:camelCaseName, ['$' . substitute(l:property, '^_', '', '') ], "$this->" . l:property . " = $" . substitute(l:property, '^_', '', '') . ";\n") |
| 139 | + if g:vim_php_refactoring_make_setter_fluent > 0 |
| 140 | + call s:PhpInsertFluent() |
| 141 | + endif |
131 | 142 | endif |
132 | 143 | if search(s:php_regex_func_line . "get" . l:camelCaseName . '\>', 'n') == 0 |
133 | 144 | call s:PhpInsertMethod("public", "get" . l:camelCaseName, [], "return $this->" . l:property . ";\n") |
@@ -525,3 +536,17 @@ function! s:PhpEchoError(message) " {{{ |
525 | 536 | echohl NONE |
526 | 537 | endfunction |
527 | 538 | " }}} |
| 539 | + |
| 540 | +function! s:PhpInsertFluent() " {{{ |
| 541 | + if g:vim_php_refactoring_make_setter_fluent == 1 |
| 542 | + exec s:php_fluent_this |
| 543 | + elseif g:vim_php_refactoring_make_setter_fluent == 2 |
| 544 | + call s:PhpEchoError('Make fluent?') |
| 545 | + if inputlist(["0. No", "1. Yes"]) == 1 |
| 546 | + exec s:php_fluent_this |
| 547 | + endif |
| 548 | + else |
| 549 | + echoerr 'Invalid option for g:vim_php_refactoring_make_setter_fluent' |
| 550 | + endif |
| 551 | +endfunction |
| 552 | +" }}} |
0 commit comments