mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-08 20:43:31 +08:00
Experimental code for showing results as soon as each linter completes
This commit is contained in:
@@ -33,17 +33,12 @@ function! ale#engine#InitBufferInfo(buffer) abort
|
||||
if !has_key(g:ale_buffer_info, a:buffer)
|
||||
" job_list will hold the list of jobs
|
||||
" loclist holds the loclist items after all jobs have completed.
|
||||
" lint_file_loclist holds items from the last run including linters
|
||||
" which use the lint_file option.
|
||||
" new_loclist holds loclist items while jobs are being run.
|
||||
" temporary_file_list holds temporary files to be cleaned up
|
||||
" temporary_directory_list holds temporary directories to be cleaned up
|
||||
" history holds a list of previously run commands for this buffer
|
||||
let g:ale_buffer_info[a:buffer] = {
|
||||
\ 'job_list': [],
|
||||
\ 'loclist': [],
|
||||
\ 'lint_file_loclist': [],
|
||||
\ 'new_loclist': [],
|
||||
\ 'temporary_file_list': [],
|
||||
\ 'temporary_directory_list': [],
|
||||
\ 'history': [],
|
||||
@@ -154,53 +149,66 @@ function! s:HandleExit(job_id, exit_code) abort
|
||||
" to set default values for loclist items.
|
||||
let l:linter_loclist = ale#engine#FixLocList(l:buffer, l:linter, l:linter_loclist)
|
||||
|
||||
" Add the loclist items from the linter.
|
||||
" loclist items for files which are checked go into a different list,
|
||||
" and are kept between runs.
|
||||
if l:linter.lint_file
|
||||
call extend(g:ale_buffer_info[l:buffer].lint_file_loclist, l:linter_loclist)
|
||||
else
|
||||
call extend(g:ale_buffer_info[l:buffer].new_loclist, l:linter_loclist)
|
||||
endif
|
||||
|
||||
if !empty(g:ale_buffer_info[l:buffer].job_list)
|
||||
" Wait for all jobs to complete before doing anything else.
|
||||
return
|
||||
endif
|
||||
|
||||
" Automatically remove all managed temporary files and directories
|
||||
" now that all jobs have completed.
|
||||
call ale#engine#RemoveManagedFiles(l:buffer)
|
||||
|
||||
" Combine the lint_file List and the List for everything else.
|
||||
let l:combined_list = g:ale_buffer_info[l:buffer].lint_file_loclist
|
||||
\ + g:ale_buffer_info[l:buffer].new_loclist
|
||||
" Remove previous items for this linter.
|
||||
call filter(g:ale_buffer_info[l:buffer].loclist, 'v:val.linter_name !=# l:linter.name')
|
||||
" Add the new items.
|
||||
call extend(g:ale_buffer_info[l:buffer].loclist, l:linter_loclist)
|
||||
|
||||
" Sort the loclist again.
|
||||
" We need a sorted list so we can run a binary search against it
|
||||
" for efficient lookup of the messages in the cursor handler.
|
||||
call sort(l:combined_list, 'ale#util#LocItemCompare')
|
||||
call sort(g:ale_buffer_info[l:buffer].loclist, 'ale#util#LocItemCompare')
|
||||
|
||||
" Now swap the old and new loclists, after we have collected everything
|
||||
" and sorted the list again.
|
||||
let g:ale_buffer_info[l:buffer].loclist = l:combined_list
|
||||
let g:ale_buffer_info[l:buffer].new_loclist = []
|
||||
let l:linting_is_done = empty(g:ale_buffer_info[l:buffer].job_list)
|
||||
|
||||
if l:linting_is_done
|
||||
" Automatically remove all managed temporary files and directories
|
||||
" now that all jobs have completed.
|
||||
call ale#engine#RemoveManagedFiles(l:buffer)
|
||||
|
||||
" Figure out which linters are still enabled, and remove
|
||||
" problems for linters which are no longer enabled.
|
||||
let l:name_map = {}
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
let l:name_map[l:linter.name] = 1
|
||||
endfor
|
||||
|
||||
call filter(
|
||||
\ g:ale_buffer_info[l:buffer].loclist,
|
||||
\ 'get(l:name_map, v:val.linter_name)',
|
||||
\)
|
||||
endif
|
||||
|
||||
call ale#engine#SetResults(l:buffer, g:ale_buffer_info[l:buffer].loclist)
|
||||
|
||||
" Call user autocommands. This allows users to hook into ALE's lint cycle.
|
||||
silent doautocmd User ALELint
|
||||
if l:linting_is_done
|
||||
" Call user autocommands. This allows users to hook into ALE's lint cycle.
|
||||
silent doautocmd User ALELint
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#engine#SetResults(buffer, loclist) abort
|
||||
let l:info = get(g:ale_buffer_info, a:buffer, {})
|
||||
let l:job_list = get(l:info, 'job_list', [])
|
||||
let l:linting_is_done = empty(l:job_list)
|
||||
|
||||
" Set signs first. This could potentially fix some line numbers.
|
||||
" The List could be sorted again here by SetSigns.
|
||||
if g:ale_set_signs
|
||||
call ale#sign#SetSigns(a:buffer, a:loclist)
|
||||
|
||||
if l:linting_is_done
|
||||
call ale#sign#RemoveDummySignIfNeeded(a:buffer)
|
||||
endif
|
||||
endif
|
||||
|
||||
if g:ale_set_quickfix || g:ale_set_loclist
|
||||
call ale#list#SetLists(a:buffer, a:loclist)
|
||||
|
||||
if l:linting_is_done
|
||||
call ale#list#CloseWindowIfNeeded(a:buffer)
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('*ale#statusline#Update')
|
||||
|
||||
Reference in New Issue
Block a user