mirror of
https://github.com/dense-analysis/ale.git
synced 2026-03-01 12:56:57 +08:00
#3332 Implement :ALERename! for ignoring errors
:ALERename! now ignores errors for files that cannot be modified, and modifies all other files.
This commit is contained in:
@@ -33,9 +33,10 @@ function! ale#rename#HandleTSServerResponse(conn_id, response) abort
|
||||
return
|
||||
endif
|
||||
|
||||
let l:old_name = s:rename_map[a:response.request_seq].old_name
|
||||
let l:new_name = s:rename_map[a:response.request_seq].new_name
|
||||
call remove(s:rename_map, a:response.request_seq)
|
||||
let l:options = remove(s:rename_map, a:response.request_seq)
|
||||
|
||||
let l:old_name = l:options.old_name
|
||||
let l:new_name = l:options.new_name
|
||||
|
||||
if get(a:response, 'success', v:false) is v:false
|
||||
let l:message = get(a:response, 'message', 'unknown')
|
||||
@@ -77,10 +78,16 @@ function! ale#rename#HandleTSServerResponse(conn_id, response) abort
|
||||
return
|
||||
endif
|
||||
|
||||
call ale#code_action#HandleCodeAction({
|
||||
\ 'description': 'rename',
|
||||
\ 'changes': l:changes,
|
||||
\}, v:true)
|
||||
call ale#code_action#HandleCodeAction(
|
||||
\ {
|
||||
\ 'description': 'rename',
|
||||
\ 'changes': l:changes,
|
||||
\ },
|
||||
\ {
|
||||
\ 'should_save': 1,
|
||||
\ 'force_save': get(l:options, 'force_save'),
|
||||
\ },
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! s:getChanges(workspace_edit) abort
|
||||
@@ -111,7 +118,7 @@ endfunction
|
||||
function! ale#rename#HandleLSPResponse(conn_id, response) abort
|
||||
if has_key(a:response, 'id')
|
||||
\&& has_key(s:rename_map, a:response.id)
|
||||
call remove(s:rename_map, a:response.id)
|
||||
let l:options = remove(s:rename_map, a:response.id)
|
||||
|
||||
if !has_key(a:response, 'result')
|
||||
call s:message('No rename result received from server')
|
||||
@@ -156,14 +163,20 @@ function! ale#rename#HandleLSPResponse(conn_id, response) abort
|
||||
\})
|
||||
endfor
|
||||
|
||||
call ale#code_action#HandleCodeAction({
|
||||
\ 'description': 'rename',
|
||||
\ 'changes': l:changes,
|
||||
\}, v:true)
|
||||
call ale#code_action#HandleCodeAction(
|
||||
\ {
|
||||
\ 'description': 'rename',
|
||||
\ 'changes': l:changes,
|
||||
\ },
|
||||
\ {
|
||||
\ 'should_save': 1,
|
||||
\ 'force_save': get(l:options, 'force_save'),
|
||||
\ },
|
||||
\)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OnReady(line, column, old_name, new_name, linter, lsp_details) abort
|
||||
function! s:OnReady(line, column, options, linter, lsp_details) abort
|
||||
let l:id = a:lsp_details.connection_id
|
||||
|
||||
if !ale#lsp#HasCapability(l:id, 'rename')
|
||||
@@ -195,19 +208,16 @@ function! s:OnReady(line, column, old_name, new_name, linter, lsp_details) abort
|
||||
\ l:buffer,
|
||||
\ a:line,
|
||||
\ a:column,
|
||||
\ a:new_name
|
||||
\ a:options.new_name
|
||||
\)
|
||||
endif
|
||||
|
||||
let l:request_id = ale#lsp#Send(l:id, l:message)
|
||||
|
||||
let s:rename_map[l:request_id] = {
|
||||
\ 'new_name': a:new_name,
|
||||
\ 'old_name': a:old_name,
|
||||
\}
|
||||
let s:rename_map[l:request_id] = a:options
|
||||
endfunction
|
||||
|
||||
function! s:ExecuteRename(linter, old_name, new_name) abort
|
||||
function! s:ExecuteRename(linter, options) abort
|
||||
let l:buffer = bufnr('')
|
||||
let [l:line, l:column] = getpos('.')[1:2]
|
||||
|
||||
@@ -215,12 +225,11 @@ function! s:ExecuteRename(linter, old_name, new_name) abort
|
||||
let l:column = min([l:column, len(getline(l:line))])
|
||||
endif
|
||||
|
||||
let l:Callback = function(
|
||||
\ 's:OnReady', [l:line, l:column, a:old_name, a:new_name])
|
||||
let l:Callback = function('s:OnReady', [l:line, l:column, a:options])
|
||||
call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback)
|
||||
endfunction
|
||||
|
||||
function! ale#rename#Execute() abort
|
||||
function! ale#rename#Execute(options) abort
|
||||
let l:lsp_linters = []
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
@@ -245,6 +254,10 @@ function! ale#rename#Execute() abort
|
||||
endif
|
||||
|
||||
for l:lsp_linter in l:lsp_linters
|
||||
call s:ExecuteRename(l:lsp_linter, l:old_name, l:new_name)
|
||||
call s:ExecuteRename(l:lsp_linter, {
|
||||
\ 'old_name': l:old_name,
|
||||
\ 'new_name': l:new_name,
|
||||
\ 'force_save': get(a:options, 'force_save') is 1,
|
||||
\})
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user