2017-02-07 17:55:23 -05:00
|
|
|
Before:
|
|
|
|
function! GenerateResults(buffer, output)
|
|
|
|
return [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'foo',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'bar',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'baz',
|
|
|
|
\ },
|
2017-03-11 12:39:51 -05:00
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'use this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 2,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'ignore this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 5,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'ignore this one',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 5,
|
|
|
|
\ 'col': 2,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'use this one',
|
|
|
|
\ },
|
2017-02-07 17:55:23 -05:00
|
|
|
\]
|
|
|
|
endfunction
|
|
|
|
|
2017-03-14 19:04:25 -04:00
|
|
|
function! ParseSigns()
|
|
|
|
redir => l:output
|
|
|
|
silent sign place
|
|
|
|
redir END
|
|
|
|
|
|
|
|
return map(
|
|
|
|
\ split(l:output, '\n')[2:],
|
|
|
|
\ 'matchlist(v:val, ''^.*=\(\d\+\).*=\(\d\+\).*=\(.*\)$'')[1:3]',
|
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
2017-02-07 17:55:23 -05:00
|
|
|
call ale#linter#Define('testft', {
|
|
|
|
\ 'name': 'x',
|
|
|
|
\ 'executable': 'echo',
|
|
|
|
\ 'command': 'echo',
|
|
|
|
\ 'callback': 'GenerateResults',
|
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-03-14 19:04:25 -04:00
|
|
|
unlet! g:loclist
|
2017-02-07 17:55:23 -05:00
|
|
|
delfunction GenerateResults
|
2017-03-14 19:04:25 -04:00
|
|
|
delfunction ParseSigns
|
|
|
|
call ale#linter#Reset()
|
|
|
|
sign unplace *
|
2017-02-07 17:55:23 -05:00
|
|
|
|
2017-03-09 17:45:22 -05:00
|
|
|
Given testft(A file with warnings/errors):
|
2017-02-07 17:55:23 -05:00
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
2017-03-11 12:39:51 -05:00
|
|
|
fourth line
|
|
|
|
fifth line
|
2017-02-07 17:55:23 -05:00
|
|
|
|
2017-03-14 19:04:25 -04:00
|
|
|
Execute(The current signs should be set for running a job):
|
2017-02-07 17:55:23 -05:00
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['1', '1000001', 'ALEErrorSign'],
|
|
|
|
\ ['2', '1000002', 'ALEWarningSign'],
|
|
|
|
\ ['3', '1000003', 'ALEErrorSign'],
|
2017-03-11 12:39:51 -05:00
|
|
|
\ ['4', '1000004', 'ALEErrorSign'],
|
|
|
|
\ ['5', '1000005', 'ALEErrorSign'],
|
2017-02-07 17:55:23 -05:00
|
|
|
\ ],
|
2017-03-14 19:04:25 -04:00
|
|
|
\ ParseSigns()
|
|
|
|
|
|
|
|
|
|
|
|
Execute(Loclist items with sign_id values should be kept):
|
|
|
|
exec 'sign place 1000347 line=15 name=ALEErrorSign buffer=' . bufnr('%')
|
|
|
|
exec 'sign place 1000348 line=16 name=ALEWarningSign buffer=' . bufnr('%')
|
|
|
|
|
|
|
|
let g:loclist = [
|
|
|
|
\ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347},
|
|
|
|
\ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000348},
|
|
|
|
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'},
|
|
|
|
\ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
|
|
|
\ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
|
|
|
\ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
|
|
|
\]
|
|
|
|
|
|
|
|
call ale#sign#SetSigns(bufnr('%'), g:loclist)
|
|
|
|
|
|
|
|
" Line numbers should be changed, sign_id values should be replaced,
|
|
|
|
" and items should be sorted again.
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000001},
|
|
|
|
\ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000002},
|
|
|
|
\ {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000003},
|
|
|
|
\ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000003},
|
|
|
|
\ {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000004},
|
|
|
|
\ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000004},
|
|
|
|
\ ],
|
|
|
|
\ g:loclist
|
|
|
|
|
|
|
|
" Items should be grouped again. We should see error signs, where there
|
|
|
|
" were warnings before, and errors where there were errors and where we
|
|
|
|
" now have new warnings.
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ['3', '1000001', 'ALEErrorSign'],
|
|
|
|
\ ['4', '1000002', 'ALEWarningSign'],
|
|
|
|
\ ['15', '1000003', 'ALEErrorSign'],
|
|
|
|
\ ['16', '1000004', 'ALEErrorSign'],
|
|
|
|
\ ],
|
|
|
|
\ ParseSigns()
|