mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-02 01:23:30 +08:00
Add ALEGoToImplementation (#4160)
* Add go to implementation * Add test cases for GoToImplementation * Add documentation for GoToImplementation
This commit is contained in:
@@ -175,6 +175,20 @@ Execute(ale#lsp#message#TypeDefinition() should return correct messages):
|
||||
\ ],
|
||||
\ ale#lsp#message#TypeDefinition(bufnr(''), 12, 34)
|
||||
|
||||
Execute(ale#lsp#message#Implementation() should return correct messages):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 0,
|
||||
\ 'textDocument/implementation',
|
||||
\ {
|
||||
\ 'textDocument': {
|
||||
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
|
||||
\ },
|
||||
\ 'position': {'line': 11, 'character': 33},
|
||||
\ }
|
||||
\ ],
|
||||
\ ale#lsp#message#Implementation(bufnr(''), 12, 34)
|
||||
|
||||
Execute(ale#lsp#message#References() should return correct messages):
|
||||
AssertEqual
|
||||
\ [
|
||||
@@ -335,6 +349,19 @@ Execute(ale#lsp#tsserver_message#TypeDefinition() should return correct messages
|
||||
\ ],
|
||||
\ ale#lsp#tsserver_message#TypeDefinition(bufnr(''), 347, 12)
|
||||
|
||||
Execute(ale#lsp#tsserver_message#Implementation() should return correct messages):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 0,
|
||||
\ 'ts@implementation',
|
||||
\ {
|
||||
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
||||
\ 'line': 347,
|
||||
\ 'offset': 12,
|
||||
\ }
|
||||
\ ],
|
||||
\ ale#lsp#tsserver_message#Implementation(bufnr(''), 347, 12)
|
||||
|
||||
Execute(ale#lsp#tsserver_message#References() should return correct messages):
|
||||
AssertEqual
|
||||
\ [
|
||||
|
||||
@@ -189,6 +189,10 @@ Before:
|
||||
\ 'typeDefinition': {
|
||||
\ 'dynamicRegistration': v:false,
|
||||
\ },
|
||||
\ 'implementation': {
|
||||
\ 'dynamicRegistration': v:false,
|
||||
\ 'linkSupport': v:false,
|
||||
\ },
|
||||
\ 'publishDiagnostics': {
|
||||
\ 'relatedInformation': v:true,
|
||||
\ },
|
||||
|
||||
@@ -182,6 +182,7 @@ Execute(Capabilities should be enabled when send as Dictionaries):
|
||||
\ },
|
||||
\ 'definitionProvider': {},
|
||||
\ 'typeDefinitionProvider': {},
|
||||
\ 'implementationProvider': {},
|
||||
\ 'experimental': {},
|
||||
\ 'documentHighlightProvider': v:true,
|
||||
\ 'workspaceSymbolProvider': {}
|
||||
@@ -198,6 +199,7 @@ Execute(Capabilities should be enabled when send as Dictionaries):
|
||||
\ 'hover': 1,
|
||||
\ 'definition': 1,
|
||||
\ 'typeDefinition': 1,
|
||||
\ 'implementation': 1,
|
||||
\ 'symbol_search': 1,
|
||||
\ 'rename': 1,
|
||||
\ 'code_actions': 1,
|
||||
|
||||
@@ -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