Merge everything into the one global map.

This commit is contained in:
w0rp
2016-10-24 20:21:32 +01:00
parent 0dbf08f6d5
commit c546f47cc0
13 changed files with 122 additions and 77 deletions

View File

@@ -2,10 +2,6 @@
" Description: Utility functions related to cleaning state.
function! ale#cleanup#Buffer(buffer) abort
if has_key(g:ale_buffer_loclist_map, a:buffer)
call remove(g:ale_buffer_loclist_map, a:buffer)
endif
if has_key(g:ale_buffer_info, a:buffer)
" When buffers are removed, clear all of the jobs.
for l:job in get(g:ale_buffer_info[a:buffer], 'job_list', [])

View File

@@ -46,12 +46,12 @@ function! ale#cursor#EchoCursorWarning(...) abort
let l:buffer = bufnr('%')
if !has_key(g:ale_buffer_loclist_map, l:buffer)
if !has_key(g:ale_buffer_info, l:buffer)
return
endif
let l:pos = getcurpos()
let l:loclist = g:ale_buffer_loclist_map[l:buffer]
let l:loclist = g:ale_buffer_info[l:buffer].loclist
let l:index = ale#util#BinarySearch(l:loclist, l:pos[1], l:pos[2])
if l:index >= 0

View File

@@ -26,6 +26,7 @@ function! ale#engine#InitBufferInfo(buffer) abort
\ 'job_list': [],
\ 'should_reset': 1,
\ 'dummy_sign_set': 0,
\ 'loclist': [],
\}
endif
endfunction
@@ -121,28 +122,28 @@ function! s:HandleExit(job) abort
" Set the flag for resetting the loclist to 0 again, so we won't
" empty the list later.
let g:ale_buffer_info[l:buffer].should_reset = 0
let g:ale_buffer_loclist_map[l:buffer] = []
let g:ale_buffer_info[l:buffer].loclist = []
endif
" Add the loclist items from the linter.
call extend(g:ale_buffer_loclist_map[l:buffer], l:linter_loclist)
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(g:ale_buffer_loclist_map[l:buffer], 'ale#util#LocItemCompare')
call sort(g:ale_buffer_info[l:buffer].loclist, 'ale#util#LocItemCompare')
if g:ale_set_loclist
call setloclist(0, g:ale_buffer_loclist_map[l:buffer])
call setloclist(0, g:ale_buffer_info[l:buffer].loclist)
endif
if g:ale_set_signs
call ale#sign#SetSigns(l:buffer, g:ale_buffer_loclist_map[l:buffer])
call ale#sign#SetSigns(l:buffer, g:ale_buffer_info[l:buffer].loclist)
endif
if exists('*ale#statusline#Update')
" Don't load/run if not already loaded.
call ale#statusline#Update(l:buffer, g:ale_buffer_loclist_map[l:buffer])
call ale#statusline#Update(l:buffer, g:ale_buffer_info[l:buffer].loclist)
endif
" Call user autocommands. This allows users to hook into ALE's lint cycle.
@@ -281,6 +282,15 @@ function! ale#engine#Invoke(buffer, linter) abort
endif
endfunction
" Given a buffer number, return the warnings and errors for a given buffer.
function! ale#engine#GetLoclist(buffer) abort
if !has_key(g:ale_buffer_info, a:buffer)
return []
endif
return g:ale_buffer_info[a:buffer].loclist
endfunction
" This function can be called with a timeout to wait for all jobs to finish.
" If the jobs to not finish in the given number of milliseconds,
" an exception will be thrown.

View File

@@ -27,7 +27,7 @@ function! s:SetupCount(buffer) abort
" Cache is cold, so manually ask for an update.
if !has_key(g:ale_buffer_info[a:buffer], 'count')
call ale#statusline#Update(a:buffer, get(g:ale_buffer_loclist_map, a:buffer, []))
call ale#statusline#Update(a:buffer, g:ale_buffer_info[a:buffer].loclist)
endif
return 1