|
25 | 25 | " |
26 | 26 | " - RENAME LOCAL VARIABLE |
27 | 27 | " In normal mode move the cursor so it's inside the name of the variable |
28 | | -" which you want to rename. Press <Leader>rrlv |
| 28 | +" which you want to rename. Press <Leader>rlv |
29 | 29 | " |
30 | 30 | " You will be prompted for the new name of the variable. |
31 | 31 | " |
| 32 | +" - LOCAL VARIABLE TO INSTANCE VARIABLE |
| 33 | +" In normal mode move the cursor so it's inside the name of the variable |
| 34 | +" which you want to rename. Press <Leader>rli |
| 35 | +" |
32 | 36 | " - OPTIMIZE USE |
33 | 37 | " Simple press <Leader>rou to run the optimize use refactoring. |
34 | 38 |
|
@@ -63,6 +67,24 @@ func! PhpRefactorExtractMethod() |
63 | 67 | " todo : exit visual mode |
64 | 68 | endfunc |
65 | 69 |
|
| 70 | +func! PhpRefactorLocalVariableToInstanceVariable() |
| 71 | + " check the file has been saved |
| 72 | + if &modified |
| 73 | + echom 'Cannot refactor; file contains unsaved changes' |
| 74 | + return |
| 75 | + endif |
| 76 | + |
| 77 | + let variable=expand('<cword>') |
| 78 | + let lineNo=line('.') |
| 79 | + |
| 80 | + exec ':!'.g:php_refactor_command |
| 81 | + \ .' convert-local-to-instance-variable' |
| 82 | + \ .' %' |
| 83 | + \ .' '.lineNo |
| 84 | + \ .' '.variable |
| 85 | + \ .' | '.g:php_refactor_patch_command |
| 86 | +endfunc |
| 87 | + |
66 | 88 | func! PhpRefactorRenameLocalVariable() |
67 | 89 | " check the file has been saved |
68 | 90 | if &modified |
@@ -98,6 +120,6 @@ func! PhpRefactorOptimizeUse() |
98 | 120 | endfunc |
99 | 121 |
|
100 | 122 | vnoremap <expr> <Leader>rem PhpRefactorExtractMethod() |
101 | | -noremap <expr> <Leader>rrlv PhpRefactorRenameLocalVariable() |
| 123 | +noremap <expr> <Leader>rlv PhpRefactorRenameLocalVariable() |
| 124 | +noremap <expr> <Leader>rli PhpRefactorLocalVariableToInstanceVariable() |
102 | 125 | noremap <expr> <Leader>rou PhpRefactorOptimizeUse() |
103 | | -
|
|
0 commit comments