diff options
-rw-r--r-- | ale_linters/java/checkstyle.vim | 4 | ||||
-rw-r--r-- | autoload/ale/completion.vim | 31 | ||||
-rw-r--r-- | autoload/ale/debugging.vim | 6 | ||||
-rw-r--r-- | autoload/ale/fix.vim | 5 | ||||
-rw-r--r-- | test/completion/test_completion_events.vader | 36 | ||||
-rw-r--r-- | test/completion/test_lsp_completion_messages.vader | 6 | ||||
-rw-r--r-- | test/completion/test_omnifunc_completion.vader | 12 | ||||
-rw-r--r-- | test/completion/test_public_completion_api.vader | 21 | ||||
-rw-r--r-- | test/handler/test_checkstyle_handler.vader | 8 | ||||
-rw-r--r-- | test/test_ale_info_to_clipboard.vader | 15 |
10 files changed, 65 insertions, 79 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim index 3159cd55..cc93ee8a 100644 --- a/ale_linters/java/checkstyle.vim +++ b/ale_linters/java/checkstyle.vim @@ -17,6 +17,10 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort \}) endfor + if !empty(l:output) + return l:output + endif + " old checkstyle versions let l:pattern = '\v(.+):(\d+): ([^:]+): (.+)$' diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 9a8b76c7..9158f227 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -216,18 +216,6 @@ function! ale#completion#GetCompletionPosition() abort endfunction function! ale#completion#GetCompletionResult() abort - " Parse a new response if there is one. - if exists('b:ale_completion_response') - \&& exists('b:ale_completion_parser') - let l:response = b:ale_completion_response - let l:parser = b:ale_completion_parser - - unlet b:ale_completion_response - unlet b:ale_completion_parser - - let b:ale_completion_result = function(l:parser)(l:response) - endif - if exists('b:ale_completion_result') return b:ale_completion_result endif @@ -247,15 +235,20 @@ function! ale#completion#AutomaticOmniFunc(findstart, base) abort endif endfunction -function! ale#completion#Show(response, completion_parser) abort +function! ale#completion#Show(result) abort if ale#util#Mode() isnot# 'i' return endif " Set the list in the buffer, temporarily replace omnifunc with our " function, and then start omni-completion. - let b:ale_completion_response = a:response - let b:ale_completion_parser = a:completion_parser + let b:ale_completion_result = a:result + + " Don't try to open the completion menu if there's nothing to show. + if empty(b:ale_completion_result) + return + endif + " Replace completion options shortly before opening the menu. call s:ReplaceCompletionOptions() @@ -475,8 +468,7 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort endif elseif l:command is# 'completionEntryDetails' call ale#completion#Show( - \ a:response, - \ 'ale#completion#ParseTSServerCompletionEntryDetails', + \ ale#completion#ParseTSServerCompletionEntryDetails(a:response), \) endif endfunction @@ -488,8 +480,7 @@ function! ale#completion#HandleLSPResponse(conn_id, response) abort endif call ale#completion#Show( - \ a:response, - \ 'ale#completion#ParseLSPCompletions', + \ ale#completion#ParseLSPCompletions(a:response), \) endfunction @@ -585,8 +576,6 @@ function! ale#completion#GetCompletions(source) abort \ 'request_id': 0, \ 'source': a:source, \} - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result let l:buffer = bufnr('') diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim index e4bf5e7e..7cdbabaa 100644 --- a/autoload/ale/debugging.vim +++ b/autoload/ale/debugging.vim @@ -238,6 +238,12 @@ function! ale#debugging#Info() abort endfunction function! ale#debugging#InfoToClipboard() abort + if !has('clipboard') + call s:Echo('clipboard not available. Try :ALEInfoToFile instead.') + + return + endif + redir => l:output silent call ale#debugging#Info() redir END diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 68b70d6a..2b9555bf 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -4,8 +4,9 @@ call ale#Set('fix_on_save_ignore', {}) " Vim doesn't let you modify hidden buffers. function! ale#fix#ApplyQueuedFixes(buffer) abort let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0}) + let l:has_bufline_api = exists('*deletebufline') && exists('*setbufline') - if !l:data.done || (!exists('*deletebufline') && a:buffer isnot bufnr('')) + if !l:data.done || (!l:has_bufline_api && a:buffer isnot bufnr('')) return endif @@ -21,7 +22,7 @@ function! ale#fix#ApplyQueuedFixes(buffer) abort let l:first_line_to_remove = len(l:new_lines) + 1 " Use a Vim API for setting lines in other buffers, if available. - if exists('*deletebufline') + if l:has_bufline_api call setbufline(a:buffer, 1, l:new_lines) call deletebufline(a:buffer, l:first_line_to_remove, '$') " Fall back on setting lines the old way, for the current buffer. diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index ebdcb5df..6bc0035e 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -57,8 +57,6 @@ After: unlet! b:ale_old_omnifunc unlet! b:ale_old_completeopt unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result unlet! b:ale_complete_done_time @@ -136,7 +134,7 @@ Execute(ale#completion#Show() should remember the omnifunc setting and replace i let &l:omnifunc = 'FooBar' let b:ale_completion_info = {'source': 'ale-automatic'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'FooBar', b:ale_old_omnifunc AssertEqual 'ale#completion#AutomaticOmniFunc', &l:omnifunc @@ -149,7 +147,7 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac let &l:completeopt = 'menu' let b:ale_completion_info = {'source': 'ale-automatic'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'menu', b:ale_old_completeopt AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt @@ -162,7 +160,7 @@ Execute(ale#completion#Show() should set the preview option if it's set): let &l:completeopt = 'menu,preview' let b:ale_completion_info = {'source': 'ale-automatic'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'menu,preview', b:ale_old_completeopt AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt @@ -176,7 +174,7 @@ Execute(ale#completion#Show() should not replace the completeopt setting for man let &l:completeopt = 'menu,preview' - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) Assert !exists('b:ale_old_completeopt') @@ -204,7 +202,7 @@ Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's Execute(ale#completion#Show() should make the correct feedkeys() call for automatic completion): let b:ale_completion_info = {'source': 'ale-automatic'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual [], g:feedkeys_calls sleep 1ms @@ -212,7 +210,7 @@ Execute(ale#completion#Show() should make the correct feedkeys() call for automa Execute(ale#completion#Show() should make the correct feedkeys() call for manual completion): let b:ale_completion_info = {'source': 'ale-automatic'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual [], g:feedkeys_calls sleep 1ms @@ -220,7 +218,7 @@ Execute(ale#completion#Show() should make the correct feedkeys() call for manual Execute(ale#completion#Show() should not call feedkeys() for other sources): let b:ale_completion_info = {'source': 'deoplete'} - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) sleep 1ms AssertEqual [], g:feedkeys_calls @@ -229,20 +227,22 @@ Execute(ale#completion#Show() shouldn't do anything if you switch back to normal let &l:completeopt = 'menu,preview' let g:fake_mode = 'n' - call ale#completion#Show('Response', 'Parser') + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) AssertEqual 'menu,preview', &l:completeopt Assert !exists('b:ale_old_omnifunc') Assert !exists('b:ale_old_completeopt') - Assert !exists('b:ale_completion_response') - Assert !exists('b:ale_completion_parser') + Assert !exists('b:ale_completion_result') AssertEqual [], g:feedkeys_calls -Execute(ale#completion#Show() should set up the response and parser): - call ale#completion#Show('Response', 'Parser') +Execute(ale#completion#Show() should save the result it is given): + call ale#completion#Show([]) + + AssertEqual [], b:ale_completion_result + + call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) - AssertEqual 'Response', b:ale_completion_response - AssertEqual 'Parser', b:ale_completion_parser + AssertEqual [{'word': 'x', 'kind': 'v', 'icase': 1}], b:ale_completion_result Execute(ale#completion#Done() should restore old omnifunc values): let b:ale_old_omnifunc = 'FooBar' @@ -317,8 +317,6 @@ Execute(b:ale_completion_info should be set up correctly when requesting complet Execute(b:ale_completion_info should be set up correctly for other sources): let b:ale_completion_result = [] - let b:ale_completion_response = [] - let b:ale_completion_parser = 'type' call setpos('.', [bufnr(''), 3, 14, 0]) call ale#completion#GetCompletions('deoplete') @@ -334,8 +332,6 @@ Execute(b:ale_completion_info should be set up correctly for other sources): \ }, \ b:ale_completion_info Assert !exists('b:ale_completion_result') - Assert !exists('b:ale_completion_response') - Assert !exists('b:ale_completion_parser') Execute(The correct keybinds should be configured): redir => g:output diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader index 25536436..9598e5f0 100644 --- a/test/completion/test_lsp_completion_messages.vader +++ b/test/completion/test_lsp_completion_messages.vader @@ -69,8 +69,6 @@ After: unlet! b:ale_old_omnifunc unlet! b:ale_old_completeopt unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_complete_done_time unlet! b:ale_linters unlet! b:ale_tsserver_completion_names @@ -246,14 +244,14 @@ Execute(Two completion requests shouldn't be sent in a row): \ 'lsp': 'stdio', \ 'executable': 'foo', \ 'command': 'foo', - \ 'project_root_callback': {-> '/foo/bar'}, + \ 'project_root': {-> '/foo/bar'}, \}) call ale#linter#Define('python', { \ 'name': 'bar', \ 'lsp': 'stdio', \ 'executable': 'foo', \ 'command': 'foo', - \ 'project_root_callback': {-> '/foo/bar'}, + \ 'project_root': {-> '/foo/bar'}, \}) let b:ale_linters = ['foo', 'bar'] diff --git a/test/completion/test_omnifunc_completion.vader b/test/completion/test_omnifunc_completion.vader index 221d337f..3711f974 100644 --- a/test/completion/test_omnifunc_completion.vader +++ b/test/completion/test_omnifunc_completion.vader @@ -1,7 +1,5 @@ Before: unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result let b:lsp_started = 0 @@ -12,27 +10,19 @@ Before: return b:lsp_started endfunction - function! Identity(x) abort - return a:x - endfunction - function! SetCompletionResult(...) abort let b:ale_completion_result = ['foo'] endfunction function! SetCompletionResponse(...) abort - let b:ale_completion_response = ['foo'] - let b:ale_completion_parser = 'Identity' + let b:ale_completion_result = ['foo'] endfunction After: unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result unlet! b:lsp_started - delfunction Identity delfunction SetCompletionResult delfunction SetCompletionResponse diff --git a/test/completion/test_public_completion_api.vader b/test/completion/test_public_completion_api.vader index d4db2d6f..befbb436 100644 --- a/test/completion/test_public_completion_api.vader +++ b/test/completion/test_public_completion_api.vader @@ -3,42 +3,21 @@ Before: unlet! b:ale_linters unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result - function! Identity(x) abort - return a:x - endfunction - After: - delfunction Identity - call ale#linter#Reset() unlet! b:ale_linters unlet! b:ale_completion_info - unlet! b:ale_completion_response - unlet! b:ale_completion_parser unlet! b:ale_completion_result Execute(ale#completion#GetCompletionResult() should return v:null when there are no results): AssertEqual v:null, ale#completion#GetCompletionResult() -Execute(ale#completion#GetCompletionResult() should parse the result when it has yet to be parsed): - let b:ale_completion_response = [1] - let b:ale_completion_parser = 'Identity' - - AssertEqual [1], ale#completion#GetCompletionResult() - Assert !exists('b:ale_completion_response') - Assert !exists('b:ale_completion_parser') - AssertEqual [1], b:ale_completion_result - Execute(ale#completion#GetCompletionResult() should return a result computed previously): let b:ale_completion_result = [1] - Assert !exists('b:ale_completion_response') - Assert !exists('b:ale_completion_parser') AssertEqual [1], ale#completion#GetCompletionResult() Execute(ale#completion#GetCompletionPosition() should return 0 when there is no completion information): diff --git a/test/handler/test_checkstyle_handler.vader b/test/handler/test_checkstyle_handler.vader index 218fe344..c60bbc82 100644 --- a/test/handler/test_checkstyle_handler.vader +++ b/test/handler/test_checkstyle_handler.vader @@ -21,10 +21,18 @@ Execute(The checkstyle handler should parse lines correctly): \ 'code': 'JavadocMethod', \ 'type': 'W', \ }, + \ { + \ 'lnum': 11, + \ 'col': 7, + \ 'text': 'WhitespaceAround: ''if'' is not followed by whitespace.', + \ 'code': 'WhitespaceAround', + \ 'type': 'W', + \ }, \ ], \ ale_linters#java#checkstyle#Handle(666, [ \ '[WARN] whatever:101: ''method def rcurly'' has incorrect indentation level 4, expected level should be 2. [Indentation]', \ '[WARN] whatever:63:3: Missing a Javadoc comment. [JavadocMethod]', + \ '[WARN] whatever:11:7: WhitespaceAround: ''if'' is not followed by whitespace. [WhitespaceAround]', \ ]) Execute(The checkstyle handler should parse lines from older checkstyle versions correctly): diff --git a/test/test_ale_info_to_clipboard.vader b/test/test_ale_info_to_clipboard.vader new file mode 100644 index 00000000..2014a310 --- /dev/null +++ b/test/test_ale_info_to_clipboard.vader @@ -0,0 +1,15 @@ +After: + unlet! g:output + +Execute(ALEInfoToClipboard should that clipboard support is required): + " When run in the Docker image, there's no clipboard support, so this test + " will actually run. + if !has('clipboard') + let g:output = '' + + redir => g:output + :ALEInfoToClipboard + redir END + + AssertEqual 'clipboard not available. Try :ALEInfoToFile instead.', join(split(g:output)) + endif |