]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_go_to_definition.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / ale / test / test_go_to_definition.vader
1 Before:
2   call ale#test#SetDirectory('/testplugin/test')
3   call ale#test#SetFilename('dummy.txt')
4
5   Save g:ale_default_navigation
6
7   let g:old_filename = expand('%:p')
8   let g:Callback = ''
9   let g:message_list = []
10   let g:expr_list = []
11   let g:capability_checked = ''
12   let g:conn_id = v:null
13   let g:InitCallback = v:null
14   let g:ale_default_navigation = 'buffer'
15
16   runtime autoload/ale/linter.vim
17   runtime autoload/ale/lsp_linter.vim
18   runtime autoload/ale/lsp.vim
19   runtime autoload/ale/util.vim
20
21   function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
22     let g:conn_id = ale#lsp#Register('executable', '/foo/bar', '', {})
23     call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
24
25     if a:linter.lsp is# 'tsserver'
26         call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
27     endif
28
29     let l:details = {
30     \ 'command': 'foobar',
31     \ 'buffer': a:buffer,
32     \ 'connection_id': g:conn_id,
33     \ 'project_root': '/foo/bar',
34     \}
35
36     let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
37   endfunction
38
39   function! ale#lsp#HasCapability(conn_id, capability) abort
40     let g:capability_checked = a:capability
41
42     return 1
43   endfunction
44
45   function! ale#lsp#RegisterCallback(conn_id, callback) abort
46     let g:Callback = a:callback
47   endfunction
48
49   function! ale#lsp#Send(conn_id, message) abort
50     call add(g:message_list, a:message)
51
52     return 42
53   endfunction
54
55   function! ale#util#Execute(expr) abort
56     call add(g:expr_list, a:expr)
57   endfunction
58
59 After:
60   Restore
61
62   if g:conn_id isnot v:null
63     call ale#lsp#RemoveConnectionWithID(g:conn_id)
64   endif
65
66   call ale#definition#SetMap({})
67   call ale#test#RestoreDirectory()
68   call ale#linter#Reset()
69
70   unlet! g:capability_checked
71   unlet! g:InitCallback
72   unlet! g:old_filename
73   unlet! g:conn_id
74   unlet! g:Callback
75   unlet! g:message_list
76   unlet! g:expr_list
77   unlet! b:ale_linters
78
79   runtime autoload/ale/lsp_linter.vim
80   runtime autoload/ale/lsp.vim
81   runtime autoload/ale/util.vim
82
83 Execute(Other messages for the tsserver handler should be ignored):
84   call ale#definition#HandleTSServerResponse(1, {'command': 'foo'})
85
86 Execute(Tagstack should be incremented if supported):
87   if exists('*gettagstack') && exists('*settagstack')
88     let original_stack_depth = gettagstack().length
89   endif
90   call ale#definition#UpdateTagStack()
91   if exists('*gettagstack') && exists('*settagstack')
92     AssertEqual original_stack_depth + 1, gettagstack().length
93   endif
94
95 Execute(Failed definition responses should be handled correctly):
96   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
97   call ale#definition#HandleTSServerResponse(
98   \ 1,
99   \ {'command': 'definition', 'request_seq': 3}
100   \)
101   AssertEqual {}, ale#definition#GetMap()
102
103 Execute(Failed definition responses with no files should be handled correctly):
104   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
105   call ale#definition#HandleTSServerResponse(
106   \ 1,
107   \ {
108   \   'command': 'definition',
109   \   'request_seq': 3,
110   \   'success': v:true,
111   \   'body': [],
112   \ }
113   \)
114   AssertEqual {}, ale#definition#GetMap()
115
116 Given typescript(Some typescript file):
117   foo
118   somelongerline
119   bazxyzxyzxyz
120
121 Execute(Other files should be jumped to for definition responses):
122   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
123   call ale#definition#HandleTSServerResponse(
124   \ 1,
125   \ {
126   \   'command': 'definition',
127   \   'request_seq': 3,
128   \   'success': v:true,
129   \   'body': [
130   \     {
131   \       'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
132   \       'start': {'line': 3, 'offset': 7},
133   \     },
134   \   ],
135   \ }
136   \)
137
138   AssertEqual
139   \ [
140   \   'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
141   \ ],
142   \ g:expr_list
143   AssertEqual [3, 7], getpos('.')[1:2]
144   AssertEqual {}, ale#definition#GetMap()
145
146 Execute(Other files should be jumped to for definition responses in tabs too):
147   call ale#definition#SetMap({3: {'open_in': 'tab'}})
148   call ale#definition#HandleTSServerResponse(
149   \ 1,
150   \ {
151   \   'command': 'definition',
152   \   'request_seq': 3,
153   \   'success': v:true,
154   \   'body': [
155   \     {
156   \       'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
157   \       'start': {'line': 3, 'offset': 7},
158   \     },
159   \   ],
160   \ }
161   \)
162
163   AssertEqual
164   \ [
165   \   'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
166   \ ],
167   \ g:expr_list
168   AssertEqual [3, 7], getpos('.')[1:2]
169   AssertEqual {}, ale#definition#GetMap()
170
171 Execute(Other files should be jumped to for definition responses in splits too):
172   call ale#definition#SetMap({3: {'open_in': 'split'}})
173   call ale#definition#HandleTSServerResponse(
174   \ 1,
175   \ {
176   \   'command': 'definition',
177   \   'request_seq': 3,
178   \   'success': v:true,
179   \   'body': [
180   \     {
181   \       'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
182   \       'start': {'line': 3, 'offset': 7},
183   \     },
184   \   ],
185   \ }
186   \)
187
188   AssertEqual
189   \ [
190   \   'split +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
191   \ ],
192   \ g:expr_list
193   AssertEqual [3, 7], getpos('.')[1:2]
194   AssertEqual {}, ale#definition#GetMap()
195
196 Execute(Other files should be jumped to for definition responses in vsplits too):
197   call ale#definition#SetMap({3: {'open_in': 'vsplit'}})
198   call ale#definition#HandleTSServerResponse(
199   \ 1,
200   \ {
201   \   'command': 'definition',
202   \   'request_seq': 3,
203   \   'success': v:true,
204   \   'body': [
205   \     {
206   \       'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
207   \       'start': {'line': 3, 'offset': 7},
208   \     },
209   \   ],
210   \ }
211   \)
212
213   AssertEqual
214   \ [
215   \   'vsplit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
216   \ ],
217   \ g:expr_list
218   AssertEqual [3, 7], getpos('.')[1:2]
219   AssertEqual {}, ale#definition#GetMap()
220
221 Execute(tsserver definition requests should be sent):
222   runtime ale_linters/typescript/tsserver.vim
223   call setpos('.', [bufnr(''), 2, 5, 0])
224
225   ALEGoToDefinition
226
227   " We shouldn't register the callback yet.
228   AssertEqual '''''', string(g:Callback)
229
230   AssertEqual type(function('type')), type(g:InitCallback)
231   call g:InitCallback()
232
233   AssertEqual 'definition', g:capability_checked
234   AssertEqual
235   \ 'function(''ale#definition#HandleTSServerResponse'')',
236   \ string(g:Callback)
237   AssertEqual
238   \ [
239   \   ale#lsp#tsserver_message#Change(bufnr('')),
240   \   [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
241   \ ],
242   \ g:message_list
243   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
244
245 Execute(tsserver type definition requests should be sent):
246   runtime ale_linters/typescript/tsserver.vim
247   call setpos('.', [bufnr(''), 2, 5, 0])
248
249   ALEGoToTypeDefinition
250
251   " We shouldn't register the callback yet.
252   AssertEqual '''''', string(g:Callback)
253
254   AssertEqual type(function('type')), type(g:InitCallback)
255   call g:InitCallback()
256
257   AssertEqual 'typeDefinition', g:capability_checked
258   AssertEqual
259   \ 'function(''ale#definition#HandleTSServerResponse'')',
260   \ string(g:Callback)
261   AssertEqual
262   \ [
263   \   ale#lsp#tsserver_message#Change(bufnr('')),
264   \   [0, 'ts@typeDefinition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
265   \ ],
266   \ g:message_list
267   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
268
269 Execute(tsserver implementation requests should be sent):
270   runtime ale_linters/typescript/tsserver.vim
271   call setpos('.', [bufnr(''), 2, 5, 0])
272
273   ALEGoToImplementation
274
275   " We shouldn't register the callback yet.
276   AssertEqual '''''', string(g:Callback)
277
278   AssertEqual type(function('type')), type(g:InitCallback)
279   call g:InitCallback()
280
281   AssertEqual 'implementation', g:capability_checked
282   AssertEqual
283   \ 'function(''ale#definition#HandleTSServerResponse'')',
284   \ string(g:Callback)
285   AssertEqual
286   \ [
287   \   ale#lsp#tsserver_message#Change(bufnr('')),
288   \   [0, 'ts@implementation', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
289   \ ],
290   \ g:message_list
291   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
292
293 Execute(tsserver tab definition requests should be sent):
294   runtime ale_linters/typescript/tsserver.vim
295   call setpos('.', [bufnr(''), 2, 5, 0])
296
297   ALEGoToDefinition -tab
298
299   " We shouldn't register the callback yet.
300   AssertEqual '''''', string(g:Callback)
301
302   AssertEqual type(function('type')), type(g:InitCallback)
303   call g:InitCallback()
304
305   AssertEqual 'definition', g:capability_checked
306   AssertEqual
307   \ 'function(''ale#definition#HandleTSServerResponse'')',
308   \ string(g:Callback)
309   AssertEqual
310   \ [
311   \   ale#lsp#tsserver_message#Change(bufnr('')),
312   \   [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
313   \ ],
314   \ g:message_list
315   AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
316
317 Execute(The default navigation type should be used):
318   runtime ale_linters/typescript/tsserver.vim
319   call setpos('.', [bufnr(''), 2, 5, 0])
320
321   let g:ale_default_navigation = 'tab'
322   ALEGoToDefinition
323
324   " We shouldn't register the callback yet.
325   AssertEqual '''''', string(g:Callback)
326
327   AssertEqual type(function('type')), type(g:InitCallback)
328   call g:InitCallback()
329
330   AssertEqual 'definition', g:capability_checked
331   AssertEqual
332   \ 'function(''ale#definition#HandleTSServerResponse'')',
333   \ string(g:Callback)
334   AssertEqual
335   \ [
336   \   ale#lsp#tsserver_message#Change(bufnr('')),
337   \   [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
338   \ ],
339   \ g:message_list
340   AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
341
342 Given python(Some Python file):
343   foo
344   somelongerline
345   bazxyzxyzxyz
346
347 Execute(Other files should be jumped to for LSP definition responses):
348   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
349   call ale#definition#HandleLSPResponse(
350   \ 1,
351   \ {
352   \   'id': 3,
353   \   'result': {
354   \     'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
355   \     'range': {
356   \       'start': {'line': 2, 'character': 7},
357   \     },
358   \   },
359   \ }
360   \)
361
362   AssertEqual
363   \ [
364   \   'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
365   \ ],
366   \ g:expr_list
367   AssertEqual [3, 8], getpos('.')[1:2]
368   AssertEqual {}, ale#definition#GetMap()
369
370 Execute(Newer LocationLink items should be supported):
371   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
372   call ale#definition#HandleLSPResponse(
373   \ 1,
374   \ {
375   \   'id': 3,
376   \   'result': {
377   \     'targetUri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
378   \     'targetRange': {
379   \       'start': {'line': 2, 'character': 7},
380   \     },
381   \   },
382   \ }
383   \)
384
385   AssertEqual
386   \ [
387   \   'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
388   \ ],
389   \ g:expr_list
390   AssertEqual [3, 8], getpos('.')[1:2]
391   AssertEqual {}, ale#definition#GetMap()
392
393 Execute(Locations inside the same file should be jumped to without using :edit):
394   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
395   call ale#definition#HandleLSPResponse(
396   \ 1,
397   \ {
398   \   'id': 3,
399   \   'result': {
400   \     'uri': ale#path#ToFileURI(ale#path#Simplify(expand('%:p'))),
401   \     'range': {
402   \       'start': {'line': 2, 'character': 7},
403   \     },
404   \   },
405   \ }
406   \)
407
408   AssertEqual
409   \ [
410   \ ],
411   \ g:expr_list
412   AssertEqual [3, 8], getpos('.')[1:2]
413   AssertEqual {}, ale#definition#GetMap()
414
415 Execute(Other files should be jumped to in tabs for LSP definition responses):
416   call ale#definition#SetMap({3: {'open_in': 'tab'}})
417   call ale#definition#HandleLSPResponse(
418   \ 1,
419   \ {
420   \   'id': 3,
421   \   'result': {
422   \     'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
423   \     'range': {
424   \       'start': {'line': 2, 'character': 7},
425   \     },
426   \   },
427   \ }
428   \)
429
430   AssertEqual
431   \ [
432   \   'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
433   \ ],
434   \ g:expr_list
435   AssertEqual [3, 8], getpos('.')[1:2]
436   AssertEqual {}, ale#definition#GetMap()
437
438 Execute(Definition responses with lists should be handled):
439   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
440   call ale#definition#HandleLSPResponse(
441   \ 1,
442   \ {
443   \   'id': 3,
444   \   'result': [
445   \     {
446   \       'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
447   \       'range': {
448   \         'start': {'line': 2, 'character': 7},
449   \       },
450   \     },
451   \     {
452   \       'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
453   \       'range': {
454   \         'start': {'line': 20, 'character': 3},
455   \       },
456   \     },
457   \   ],
458   \ }
459   \)
460
461   " Multiple results should either open the ALEPreview or go to quickfix
462   AssertEqual [1, 1], getpos('.')[1:2]
463   AssertEqual {}, ale#definition#GetMap()
464
465 Execute(Definition responses with null response should be handled):
466   call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
467   call ale#definition#HandleLSPResponse(1, {'id': 3, 'result': v:null})
468
469   AssertEqual ['echom ''No definitions found'''], g:expr_list
470
471 Execute(LSP definition requests should be sent):
472   runtime ale_linters/python/pylsp.vim
473   let b:ale_linters = ['pylsp']
474   call setpos('.', [bufnr(''), 1, 5, 0])
475
476   ALEGoToDefinition
477
478   " We shouldn't register the callback yet.
479   AssertEqual '''''', string(g:Callback)
480
481   AssertEqual type(function('type')), type(g:InitCallback)
482   call g:InitCallback()
483
484   AssertEqual 'definition', g:capability_checked
485   AssertEqual
486   \ 'function(''ale#definition#HandleLSPResponse'')',
487   \ string(g:Callback)
488
489   AssertEqual
490   \ [
491   \   [1, 'textDocument/didChange', {
492   \     'textDocument': {
493   \         'uri': ale#path#ToFileURI(expand('%:p')),
494   \         'version': g:ale_lsp_next_version_id - 1,
495   \     },
496   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
497   \   }],
498   \   [0, 'textDocument/definition', {
499   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
500   \   'position': {'line': 0, 'character': 2},
501   \   }],
502   \ ],
503   \ g:message_list
504
505   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
506
507 Execute(LSP type definition requests should be sent):
508   runtime ale_linters/python/pylsp.vim
509   let b:ale_linters = ['pylsp']
510   call setpos('.', [bufnr(''), 1, 5, 0])
511
512   ALEGoToTypeDefinition
513
514   " We shouldn't register the callback yet.
515   AssertEqual '''''', string(g:Callback)
516
517   AssertEqual type(function('type')), type(g:InitCallback)
518   call g:InitCallback()
519
520   AssertEqual 'typeDefinition', g:capability_checked
521   AssertEqual
522   \ 'function(''ale#definition#HandleLSPResponse'')',
523   \ string(g:Callback)
524
525   AssertEqual
526   \ [
527   \   [1, 'textDocument/didChange', {
528   \     'textDocument': {
529   \         'uri': ale#path#ToFileURI(expand('%:p')),
530   \         'version': g:ale_lsp_next_version_id - 1,
531   \     },
532   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
533   \   }],
534   \   [0, 'textDocument/typeDefinition', {
535   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
536   \   'position': {'line': 0, 'character': 2},
537   \   }],
538   \ ],
539   \ g:message_list
540
541   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
542
543 Execute(LSP implementation requests should be sent):
544   runtime ale_linters/python/pylsp.vim
545   let b:ale_linters = ['pylsp']
546   call setpos('.', [bufnr(''), 1, 5, 0])
547
548   ALEGoToImplementation
549
550   " We shouldn't register the callback yet.
551   AssertEqual '''''', string(g:Callback)
552
553   AssertEqual type(function('type')), type(g:InitCallback)
554   call g:InitCallback()
555
556   AssertEqual 'implementation', g:capability_checked
557   AssertEqual
558   \ 'function(''ale#definition#HandleLSPResponse'')',
559   \ string(g:Callback)
560
561   AssertEqual
562   \ [
563   \   [1, 'textDocument/didChange', {
564   \     'textDocument': {
565   \         'uri': ale#path#ToFileURI(expand('%:p')),
566   \         'version': g:ale_lsp_next_version_id - 1,
567   \     },
568   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
569   \   }],
570   \   [0, 'textDocument/implementation', {
571   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
572   \   'position': {'line': 0, 'character': 2},
573   \   }],
574   \ ],
575   \ g:message_list
576
577   AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
578
579 Execute(LSP tab definition requests should be sent):
580   runtime ale_linters/python/pylsp.vim
581   let b:ale_linters = ['pylsp']
582   call setpos('.', [bufnr(''), 1, 5, 0])
583
584   ALEGoToDefinition -tab
585
586   " We shouldn't register the callback yet.
587   AssertEqual '''''', string(g:Callback)
588
589   AssertEqual type(function('type')), type(g:InitCallback)
590   call g:InitCallback()
591
592   AssertEqual 'definition', g:capability_checked
593   AssertEqual
594   \ 'function(''ale#definition#HandleLSPResponse'')',
595   \ string(g:Callback)
596
597   AssertEqual
598   \ [
599   \   [1, 'textDocument/didChange', {
600   \     'textDocument': {
601   \         'uri': ale#path#ToFileURI(expand('%:p')),
602   \         'version': g:ale_lsp_next_version_id - 1,
603   \     },
604   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
605   \   }],
606   \   [0, 'textDocument/definition', {
607   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
608   \   'position': {'line': 0, 'character': 2},
609   \   }],
610   \ ],
611   \ g:message_list
612
613   AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
614
615 Execute(LSP tab type definition requests should be sent):
616   runtime ale_linters/python/pylsp.vim
617   let b:ale_linters = ['pylsp']
618   call setpos('.', [bufnr(''), 1, 5, 0])
619
620   ALEGoToTypeDefinition -tab
621
622   " We shouldn't register the callback yet.
623   AssertEqual '''''', string(g:Callback)
624
625   AssertEqual type(function('type')), type(g:InitCallback)
626   call g:InitCallback()
627
628   AssertEqual 'typeDefinition', g:capability_checked
629   AssertEqual
630   \ 'function(''ale#definition#HandleLSPResponse'')',
631   \ string(g:Callback)
632
633   AssertEqual
634   \ [
635   \   [1, 'textDocument/didChange', {
636   \     'textDocument': {
637   \         'uri': ale#path#ToFileURI(expand('%:p')),
638   \         'version': g:ale_lsp_next_version_id - 1,
639   \     },
640   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
641   \   }],
642   \   [0, 'textDocument/typeDefinition', {
643   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
644   \   'position': {'line': 0, 'character': 2},
645   \   }],
646   \ ],
647   \ g:message_list
648
649   AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
650
651 Execute(LSP tab implementation requests should be sent):
652   runtime ale_linters/python/pylsp.vim
653   let b:ale_linters = ['pylsp']
654   call setpos('.', [bufnr(''), 1, 5, 0])
655
656   ALEGoToImplementation -tab
657
658   " We shouldn't register the callback yet.
659   AssertEqual '''''', string(g:Callback)
660
661   AssertEqual type(function('type')), type(g:InitCallback)
662   call g:InitCallback()
663
664   AssertEqual 'implementation', g:capability_checked
665   AssertEqual
666   \ 'function(''ale#definition#HandleLSPResponse'')',
667   \ string(g:Callback)
668
669   AssertEqual
670   \ [
671   \   [1, 'textDocument/didChange', {
672   \     'textDocument': {
673   \         'uri': ale#path#ToFileURI(expand('%:p')),
674   \         'version': g:ale_lsp_next_version_id - 1,
675   \     },
676   \     'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
677   \   }],
678   \   [0, 'textDocument/implementation', {
679   \   'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
680   \   'position': {'line': 0, 'character': 2},
681   \   }],
682   \ ],
683   \ g:message_list
684
685   AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()