@@ -2,25 +2,45 @@ if !exists("g:php_refactor_patch_command")
22 let g: php_refactor_patch_command= ' patch -p1'
33endif
44
5- func ! PhpRefactorExtractMethod ()
5+ func ! PhpRefactorShowMenu () range
6+ echohl Title
7+ echo ' Available Refactorings:'
8+ echohl None
9+ echo ' (em) Extract Method'
10+ echo ' (lv) rename Local Variable'
11+ echo ' (li) Local variable to Instance variable'
12+ echo ' (ou) Optimize Use'
13+ echo ' '
14+ echo ' (c) Cancel'
15+ echo ' '
16+
17+ let choice = nr2char (getchar ())
18+ if choice == ' c'
19+ return
20+ endif
21+ let choice = choice . nr2char (getchar ())
22+
23+ if choice == ' em'
24+ call PhpRefactorExtractMethod (a: firstline , a: lastline )
25+ elseif choice == ' lv'
26+ call PhpRefactorRenameLocalVariable ()
27+ elseif choice == ' li'
28+ call PhpRefactorLocalVariableToInstanceVariable ()
29+ elseif choice == ' ou'
30+ call PhpRefactorOptimizeUse ()
31+ endif
32+ endfunc
33+
34+ func ! PhpRefactorExtractMethod (startline, endline)
635 " check the file has been saved
736 if &modified
837 echom ' Cannot refactor; file contains unsaved changes'
938 return
1039 endif
1140
12- let startLine = line (' v' )
13- let endLine = line (' .' )
1441 let method = input (' Enter extracted method name: ' )
1542
16- " check line numbers are the right way around
17- if startLine > endLine
18- let temp = startLine
19- let startLine = endLine
20- let endLine = temp
21- endif
22-
23- let range = startLine . ' -' . endLine
43+ let range = a: startline . ' -' . a: endline
2444
2545 let args = [range , method]
2646
0 commit comments