summaryrefslogtreecommitdiff
path: root/test/test_go_to_definition.vader
diff options
context:
space:
mode:
authorAndrey Popp <8mayday@gmail.com>2019-01-22 02:06:28 +0300
committerw0rp <w0rp@users.noreply.github.com>2019-01-21 23:06:28 +0000
commitd0284f22ea45a5e7796da2224373c22232af1777 (patch)
treecdb86bbb13a5d0c11f6579aeebe4deaed75e32ab /test/test_go_to_definition.vader
parenta4932679b5c0d2917a399614a25c9827d63eecb1 (diff)
downloadale-d0284f22ea45a5e7796da2224373c22232af1777.zip
Add textDocument/typeDefinition for LSP (#2226)
* Add textDocument/typeDefinition for LSP Doc to spec https://microsoft.github.io/language-server-protocol/specification#textDocument_typeDefinition This works like textDocument/definition but resolves a location of a type of an expression under the cursor. I'm not sure what to do with tsserver though. * Fix passing column to LSP * test_go_to_definition: wording * Add tests for textDocument/typeDefinition * Add docs for textDocument/typeDefinition
Diffstat (limited to 'test/test_go_to_definition.vader')
-rw-r--r--test/test_go_to_definition.vader80
1 files changed, 76 insertions, 4 deletions
diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader
index 62dbc599..3cc2a58c 100644
--- a/test/test_go_to_definition.vader
+++ b/test/test_go_to_definition.vader
@@ -196,7 +196,7 @@ Execute(Other files should be jumped to for definition responses in vsplits too)
AssertEqual [3, 7], getpos('.')[1:2]
AssertEqual {}, ale#definition#GetMap()
-Execute(tsserver completion requests should be sent):
+Execute(tsserver definition requests should be sent):
runtime ale_linters/typescript/tsserver.vim
call setpos('.', [bufnr(''), 2, 5, 0])
@@ -217,7 +217,7 @@ Execute(tsserver completion requests should be sent):
\ g:message_list
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
-Execute(tsserver tab completion requests should be sent):
+Execute(tsserver tab definition requests should be sent):
runtime ale_linters/typescript/tsserver.vim
call setpos('.', [bufnr(''), 2, 5, 0])
@@ -348,7 +348,7 @@ Execute(Definition responses with null response should be handled):
AssertEqual [], g:expr_list
-Execute(LSP completion requests should be sent):
+Execute(LSP definition requests should be sent):
runtime ale_linters/python/pyls.vim
let b:ale_linters = ['pyls']
call setpos('.', [bufnr(''), 1, 5, 0])
@@ -384,7 +384,43 @@ Execute(LSP completion requests should be sent):
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
-Execute(LSP tab completion requests should be sent):
+Execute(LSP type definition requests should be sent):
+ runtime ale_linters/python/pyls.vim
+ let b:ale_linters = ['pyls']
+ call setpos('.', [bufnr(''), 1, 5, 0])
+
+ ALEGoToTypeDefinition
+
+ " We shouldn't register the callback yet.
+ AssertEqual '''''', string(g:Callback)
+
+ AssertEqual type(function('type')), type(g:WaitCallback)
+ AssertEqual 'typeDefinition', g:capability_checked
+ call call(g:WaitCallback, [g:conn_id, '/foo/bar'])
+
+ AssertEqual
+ \ 'function(''ale#definition#HandleLSPResponse'')',
+ \ string(g:Callback)
+
+ AssertEqual
+ \ [
+ \ [1, 'textDocument/didChange', {
+ \ 'textDocument': {
+ \ 'uri': ale#path#ToURI(expand('%:p')),
+ \ 'version': g:ale_lsp_next_version_id - 1,
+ \ },
+ \ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
+ \ }],
+ \ [0, 'textDocument/typeDefinition', {
+ \ 'textDocument': {'uri': ale#path#ToURI(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/pyls.vim
let b:ale_linters = ['pyls']
call setpos('.', [bufnr(''), 1, 5, 0])
@@ -419,3 +455,39 @@ Execute(LSP tab completion requests should be sent):
\ g:message_list
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
+
+Execute(LSP tab type definition requests should be sent):
+ runtime ale_linters/python/pyls.vim
+ let b:ale_linters = ['pyls']
+ call setpos('.', [bufnr(''), 1, 5, 0])
+
+ ALEGoToTypeDefinitionInTab
+
+ " We shouldn't register the callback yet.
+ AssertEqual '''''', string(g:Callback)
+
+ AssertEqual type(function('type')), type(g:WaitCallback)
+ AssertEqual 'typeDefinition', g:capability_checked
+ call call(g:WaitCallback, [g:conn_id, '/foo/bar'])
+
+ AssertEqual
+ \ 'function(''ale#definition#HandleLSPResponse'')',
+ \ string(g:Callback)
+
+ AssertEqual
+ \ [
+ \ [1, 'textDocument/didChange', {
+ \ 'textDocument': {
+ \ 'uri': ale#path#ToURI(expand('%:p')),
+ \ 'version': g:ale_lsp_next_version_id - 1,
+ \ },
+ \ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
+ \ }],
+ \ [0, 'textDocument/typeDefinition', {
+ \ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
+ \ 'position': {'line': 0, 'character': 2},
+ \ }],
+ \ ],
+ \ g:message_list
+
+ AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()