mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-10 03:31:34 +08:00
Add ALEGoToImplementation (#4160)
* Add go to implementation * Add test cases for GoToImplementation * Add documentation for GoToImplementation
This commit is contained in:
@@ -266,6 +266,30 @@ Execute(tsserver type definition requests should be sent):
|
||||
\ g:message_list
|
||||
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
||||
|
||||
Execute(tsserver implementation requests should be sent):
|
||||
runtime ale_linters/typescript/tsserver.vim
|
||||
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||
|
||||
ALEGoToImplementation
|
||||
|
||||
" We shouldn't register the callback yet.
|
||||
AssertEqual '''''', string(g:Callback)
|
||||
|
||||
AssertEqual type(function('type')), type(g:InitCallback)
|
||||
call g:InitCallback()
|
||||
|
||||
AssertEqual 'implementation', g:capability_checked
|
||||
AssertEqual
|
||||
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
||||
\ string(g:Callback)
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
||||
\ [0, 'ts@implementation', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||
\ ],
|
||||
\ g:message_list
|
||||
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
||||
|
||||
Execute(tsserver tab definition requests should be sent):
|
||||
runtime ale_linters/typescript/tsserver.vim
|
||||
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||
@@ -520,6 +544,42 @@ Execute(LSP type definition requests should be sent):
|
||||
|
||||
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
||||
|
||||
Execute(LSP implementation requests should be sent):
|
||||
runtime ale_linters/python/pylsp.vim
|
||||
let b:ale_linters = ['pylsp']
|
||||
call setpos('.', [bufnr(''), 1, 5, 0])
|
||||
|
||||
ALEGoToImplementation
|
||||
|
||||
" We shouldn't register the callback yet.
|
||||
AssertEqual '''''', string(g:Callback)
|
||||
|
||||
AssertEqual type(function('type')), type(g:InitCallback)
|
||||
call g:InitCallback()
|
||||
|
||||
AssertEqual 'implementation', g:capability_checked
|
||||
AssertEqual
|
||||
\ 'function(''ale#definition#HandleLSPResponse'')',
|
||||
\ string(g:Callback)
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ [1, 'textDocument/didChange', {
|
||||
\ 'textDocument': {
|
||||
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
||||
\ 'version': g:ale_lsp_next_version_id - 1,
|
||||
\ },
|
||||
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
||||
\ }],
|
||||
\ [0, 'textDocument/implementation', {
|
||||
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
||||
\ 'position': {'line': 0, 'character': 2},
|
||||
\ }],
|
||||
\ ],
|
||||
\ g:message_list
|
||||
|
||||
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
||||
|
||||
Execute(LSP tab definition requests should be sent):
|
||||
runtime ale_linters/python/pylsp.vim
|
||||
let b:ale_linters = ['pylsp']
|
||||
@@ -591,3 +651,39 @@ Execute(LSP tab type definition requests should be sent):
|
||||
\ g:message_list
|
||||
|
||||
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
||||
|
||||
Execute(LSP tab implementation requests should be sent):
|
||||
runtime ale_linters/python/pylsp.vim
|
||||
let b:ale_linters = ['pylsp']
|
||||
call setpos('.', [bufnr(''), 1, 5, 0])
|
||||
|
||||
ALEGoToImplementation -tab
|
||||
|
||||
" We shouldn't register the callback yet.
|
||||
AssertEqual '''''', string(g:Callback)
|
||||
|
||||
AssertEqual type(function('type')), type(g:InitCallback)
|
||||
call g:InitCallback()
|
||||
|
||||
AssertEqual 'implementation', g:capability_checked
|
||||
AssertEqual
|
||||
\ 'function(''ale#definition#HandleLSPResponse'')',
|
||||
\ string(g:Callback)
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ [1, 'textDocument/didChange', {
|
||||
\ 'textDocument': {
|
||||
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
||||
\ 'version': g:ale_lsp_next_version_id - 1,
|
||||
\ },
|
||||
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
||||
\ }],
|
||||
\ [0, 'textDocument/implementation', {
|
||||
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
||||
\ 'position': {'line': 0, 'character': 2},
|
||||
\ }],
|
||||
\ ],
|
||||
\ g:message_list
|
||||
|
||||
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
||||
|
||||
Reference in New Issue
Block a user