Skip to content

Commit

Permalink
[#7] TsuRenameSymbolC works
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Jul 27, 2015
1 parent b7f6eee commit 73bc5db
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions autoload/tsuquyomi/tsClient.vim
Expand Up @@ -434,7 +434,7 @@ endfunction
" PARAM: {int} line The line number of the symbol's position.
" PARAM: {int} offset The col number of the symbol's position.
" PARAM: {0|1} findInComments Whether result contains word in comments.
" PARAM: {0|1} findInComments Whether result contains word in String literals.
" PARAM: {0|1} findInString Whether result contains word in String literals.
" RETURNS: {dict} Rename information dictionary.
" e.g.:
" {
Expand All @@ -460,7 +460,7 @@ endfunction
" ]
" }
function! tsuquyomi#tsClient#tsRename(file, line, offset, findInComments, findInString)
" TODO findInComments and findInString parameters don't work... why?
" TODO findInString parameter does not work... why?
let l:arg = {'file': a:file, 'line': a:line, 'offset': a:offset,
\ 'findInComments': a:findInComments ? s:JSON.true : s:JSON.false,
\ 'findInString' : a:findInString ? s:JSON.true : s:JSON.false
Expand Down
8 changes: 4 additions & 4 deletions ftplugin/typescript.vim
Expand Up @@ -39,10 +39,10 @@ command! -buffer TsuquyomiGeterr :call tsuquyomi#geterr()
command! -buffer TsuGeterr :call tsuquyomi#geterr()
command! -buffer TsuquyomiRenameSymbol :call tsuquyomi#renameSymbol()
command! -buffer TsuRenameSymbol :call tsuquyomi#renameSymbol()

" TODO These commands don't work correctly. [#7]
command! -buffer TsuquyomiRenameSymbolC :call tsuquyomi#renameSymbolWithComments()
command! -buffer TsuRenameSymbolC :call tsuquyomi#renameSymbolWithComments()

" TODO These commands don't work correctly.
command! -buffer TsuquyomiRenameSymbolS :call tsuquyomi#renameSymbolWithStrings()
command! -buffer TsuRenameSymbolS :call tsuquyomi#renameSymbolWithStrings()
command! -buffer TsuquyomiRenameSymbolCS :call tsuquyomi#renameSymbolWithCommentsStrings()
Expand All @@ -52,9 +52,9 @@ noremap <silent> <buffer> <Plug>(TsuquyomiDefinition) :TsuquyomiDefinition <
noremap <silent> <buffer> <Plug>(TsuquyomiGoBack) :TsuquyomiGoBack <CR>
noremap <silent> <buffer> <Plug>(TsuquyomiReferences) :TsuquyomiReferences <CR>
noremap <silent> <buffer> <Plug>(TsuquyomiRenameSymbol) :TsuquyomiRenameSymbol <CR>
" TODO These commands don't work correctly. [#7]
noremap <silent> <buffer> <Plug>(TsuquyomiRenameSymbolC) :TsuquyomiRenameSymbolC <CR>
" TODO These commands don't work correctly.
noremap <silent> <buffer> <Plug>(TsuquyomiRenameSymbolS) :TsuquyomiRenameSymbolS <CR>
noremap <silent> <buffer> <Plug>(TsuquyomiRenameSymbolCS) :TsuquyomiRenameSymbolCS <CR>
Expand Down
7 changes: 7 additions & 0 deletions vest/resources/renameTest.ts
Expand Up @@ -10,4 +10,11 @@ module Test {
**/
var someFunc = (bar: string) => { };

var otherFunc = () => {
var prefix;
console.log(' prefix ');
console.log(" prefix ");
console.log(` prefix `);
}

}
17 changes: 16 additions & 1 deletion vest/tsRename.spec.vim
Expand Up @@ -54,7 +54,6 @@ Context Vesting.run()
let file = s:Filepath.join(s:script_dir, 'vest/resources/renameTest.ts')
call tsuquyomi#tsClient#tsOpen(file)
let result_rename_dict = tsuquyomi#tsClient#tsRename(file, 3, 9, 0, 0)
echo result_rename_dict
Should len(result_rename_dict.locs[0].locs) == 3
Should result_rename_dict.locs[0].locs[0].start.line == 4
Should result_rename_dict.locs[0].locs[0].start.offset == 13
Expand All @@ -65,5 +64,21 @@ Context Vesting.run()
call tsuquyomi#tsClient#stopTss()
End

It can rename variables in comments.
let file = s:Filepath.join(s:script_dir, 'vest/resources/renameTest.ts')
call tsuquyomi#tsClient#tsOpen(file)
let result_rename_dict = tsuquyomi#tsClient#tsRename(file, 11, 21, 1, 0)
Should len(result_rename_dict.locs[0].locs) == 2
Should result_rename_dict.locs[0].locs[1].start.line == 8
Should result_rename_dict.locs[0].locs[1].start.offset == 15
End

" It can rename identifiers in strings.
" let file = s:Filepath.join(s:script_dir, 'vest/resources/renameTest.ts')
" call tsuquyomi#tsClient#tsOpen(file)
" let result_rename_dict = tsuquyomi#tsClient#tsRename(file, 14, 13, 0, 1)
" Should len(result_rename_dict.locs[0].locs) == 4
" End

End
Fin

0 comments on commit 73bc5db

Please sign in to comment.