2017-06-07 16:05:28 +00:00
|
|
|
Before:
|
2017-07-26 09:37:37 +00:00
|
|
|
let g:ale_lsp_next_version_id = 1
|
|
|
|
|
2017-09-09 17:39:56 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/lsp')
|
2017-07-26 09:37:37 +00:00
|
|
|
call ale#test#SetFilename('foo/bar.ts')
|
2017-06-07 16:05:28 +00:00
|
|
|
|
|
|
|
After:
|
2017-09-09 17:39:56 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-06-07 16:05:28 +00:00
|
|
|
|
2017-05-08 21:18:28 +00:00
|
|
|
Execute(ale#lsp#message#Initialize() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'initialize',
|
|
|
|
\ {
|
|
|
|
\ 'processId': getpid(),
|
2017-07-26 09:37:37 +00:00
|
|
|
\ 'rootPath': '/foo/bar',
|
2017-05-08 21:18:28 +00:00
|
|
|
\ 'capabilities': {},
|
2018-06-06 15:58:49 +00:00
|
|
|
\ 'initializationOptions': {'foo': 'bar'},
|
2018-06-06 15:59:44 +00:00
|
|
|
\ 'rootUri': 'file:///foo/bar',
|
2017-05-08 21:18:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
2018-06-06 15:58:49 +00:00
|
|
|
\ ale#lsp#message#Initialize('/foo/bar', {'foo': 'bar'})
|
2017-05-08 21:18:28 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#message#Initialized() should return correct messages):
|
|
|
|
AssertEqual [1, 'initialized'], ale#lsp#message#Initialized()
|
|
|
|
|
|
|
|
Execute(ale#lsp#message#Shutdown() should return correct messages):
|
|
|
|
AssertEqual [0, 'shutdown'], ale#lsp#message#Shutdown()
|
|
|
|
|
|
|
|
Execute(ale#lsp#message#Exit() should return correct messages):
|
|
|
|
AssertEqual [1, 'exit'], ale#lsp#message#Exit(),
|
|
|
|
|
2017-07-26 09:37:37 +00:00
|
|
|
Given typescript(A TypeScript file with 3 lines):
|
|
|
|
foo()
|
|
|
|
bar()
|
|
|
|
baz()
|
|
|
|
|
2017-05-08 21:18:28 +00:00
|
|
|
Execute(ale#lsp#message#DidOpen() should return correct messages):
|
2017-07-26 09:37:37 +00:00
|
|
|
let g:ale_lsp_next_version_id = 12
|
2017-05-08 21:18:28 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'textDocument/didOpen',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
2017-09-09 17:39:56 +00:00
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
2017-05-08 21:18:28 +00:00
|
|
|
\ 'languageId': 'typescript',
|
2017-07-26 09:37:37 +00:00
|
|
|
\ 'version': 12,
|
2017-11-05 21:41:53 +00:00
|
|
|
\ 'text': "foo()\nbar()\nbaz()\n",
|
2017-05-08 21:18:28 +00:00
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\ ],
|
2017-07-26 09:37:37 +00:00
|
|
|
\ ale#lsp#message#DidOpen(bufnr(''), 'typescript')
|
2017-05-08 21:18:28 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#message#DidChange() should return correct messages):
|
2017-07-26 09:37:37 +00:00
|
|
|
let g:ale_lsp_next_version_id = 34
|
|
|
|
|
2017-05-08 21:18:28 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'textDocument/didChange',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
2017-09-09 17:39:56 +00:00
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
2017-07-26 09:37:37 +00:00
|
|
|
\ 'version': 34,
|
2017-05-08 21:18:28 +00:00
|
|
|
\ },
|
2017-11-05 21:41:53 +00:00
|
|
|
\ 'contentChanges': [{'text': "foo()\nbar()\nbaz()\n"}],
|
2017-05-08 21:18:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
2017-07-26 09:37:37 +00:00
|
|
|
\ ale#lsp#message#DidChange(bufnr(''))
|
|
|
|
" The version numbers should increment.
|
|
|
|
AssertEqual
|
|
|
|
\ 35,
|
|
|
|
\ ale#lsp#message#DidChange(bufnr(''))[2].textDocument.version
|
|
|
|
AssertEqual
|
|
|
|
\ 36,
|
|
|
|
\ ale#lsp#message#DidChange(bufnr(''))[2].textDocument.version
|
2017-05-08 21:18:28 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#message#DidSave() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'textDocument/didSave',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
2017-09-09 17:39:56 +00:00
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
2017-05-08 21:18:28 +00:00
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\ ],
|
2017-07-26 09:37:37 +00:00
|
|
|
\ ale#lsp#message#DidSave(bufnr(''))
|
2017-05-08 21:18:28 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#message#DidClose() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'textDocument/didClose',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
2017-09-09 17:39:56 +00:00
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
2017-05-08 21:18:28 +00:00
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\ ],
|
2017-07-26 09:37:37 +00:00
|
|
|
\ ale#lsp#message#DidClose(bufnr(''))
|
2017-06-07 16:05:28 +00:00
|
|
|
|
2017-11-26 12:24:18 +00:00
|
|
|
Execute(ale#lsp#message#Completion() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'textDocument/completion',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
|
|
|
\ },
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 11, 'character': 33},
|
2017-11-26 12:24:18 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#Completion(bufnr(''), 12, 34, '')
|
|
|
|
|
|
|
|
Execute(ale#lsp#message#Completion() should return correct messages with a trigger charaacter):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'textDocument/completion',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
|
|
|
\ },
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 11, 'character': 33},
|
2017-11-26 12:24:18 +00:00
|
|
|
\ 'context': {'triggerKind': 2, 'triggerCharacter': '.'},
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#Completion(bufnr(''), 12, 34, '.')
|
2017-11-26 22:27:08 +00:00
|
|
|
\
|
|
|
|
Execute(ale#lsp#message#Definition() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'textDocument/definition',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
|
|
|
\ },
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 11, 'character': 33},
|
2017-11-26 22:27:08 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#Definition(bufnr(''), 12, 34)
|
2017-11-26 12:24:18 +00:00
|
|
|
|
2018-04-22 18:49:24 +00:00
|
|
|
Execute(ale#lsp#message#References() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'textDocument/references',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
|
|
|
\ },
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 11, 'character': 33},
|
2018-04-22 18:49:24 +00:00
|
|
|
\ 'context': {'includeDeclaration': v:false},
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#References(bufnr(''), 12, 34)
|
|
|
|
|
2018-10-31 16:13:22 +00:00
|
|
|
Execute(ale#lsp#message#Symbol() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'workspace/symbol',
|
|
|
|
\ {
|
|
|
|
\ 'query': 'foobar',
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#Symbol('foobar')
|
|
|
|
|
2018-04-22 21:00:25 +00:00
|
|
|
Execute(ale#lsp#message#Hover() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'textDocument/hover',
|
|
|
|
\ {
|
|
|
|
\ 'textDocument': {
|
|
|
|
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
|
|
|
|
\ },
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 11, 'character': 33},
|
2018-04-22 21:00:25 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#Hover(bufnr(''), 12, 34)
|
|
|
|
|
2018-10-22 12:24:46 +00:00
|
|
|
Execute(ale#lsp#message#DidChangeConfiguration() should return correct messages):
|
|
|
|
let g:ale_lsp_configuration = {
|
|
|
|
\ 'foo': 'bar'
|
|
|
|
\ }
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'workspace/didChangeConfiguration',
|
|
|
|
\ {
|
|
|
|
\ 'settings': {
|
|
|
|
\ 'foo': 'bar',
|
|
|
|
\ }
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#message#DidChangeConfiguration(bufnr(''), g:ale_lsp_configuration)
|
|
|
|
|
2017-06-07 16:05:28 +00:00
|
|
|
Execute(ale#lsp#tsserver_message#Open() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'ts@open',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-06-07 16:05:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Open(bufnr(''))
|
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Close() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'ts@close',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-06-07 16:05:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Close(bufnr(''))
|
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Change() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 1,
|
|
|
|
\ 'ts@change',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-06-07 16:05:28 +00:00
|
|
|
\ 'line': 1,
|
|
|
|
\ 'offset': 1,
|
2017-06-08 16:28:38 +00:00
|
|
|
\ 'endLine': 1073741824,
|
|
|
|
\ 'endOffset': 1,
|
2017-11-05 21:41:53 +00:00
|
|
|
\ 'insertString': "foo()\nbar()\nbaz()\n",
|
2017-06-07 16:05:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Change(bufnr(''))
|
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Geterr() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2017-06-13 16:53:47 +00:00
|
|
|
\ 1,
|
2017-06-07 16:05:28 +00:00
|
|
|
\ 'ts@geterr',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'files': [ale#path#Simplify(g:dir . '/foo/bar.ts')],
|
2017-06-07 16:05:28 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Geterr(bufnr(''))
|
2017-07-01 00:22:03 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Completions() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'ts@completions',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-07-01 00:22:03 +00:00
|
|
|
\ 'line': 347,
|
|
|
|
\ 'offset': 12,
|
2017-07-01 23:28:00 +00:00
|
|
|
\ 'prefix': 'abc',
|
2017-07-01 00:22:03 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
2017-07-01 23:28:00 +00:00
|
|
|
\ ale#lsp#tsserver_message#Completions(bufnr(''), 347, 12, 'abc')
|
2017-07-01 00:22:03 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#CompletionEntryDetails() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'ts@completionEntryDetails',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-07-01 00:22:03 +00:00
|
|
|
\ 'line': 347,
|
|
|
|
\ 'offset': 12,
|
|
|
|
\ 'entryNames': ['foo', 'bar'],
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#CompletionEntryDetails(bufnr(''), 347, 12, ['foo', 'bar'])
|
2017-11-21 00:21:45 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Definition() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'ts@definition',
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
2017-11-21 00:21:45 +00:00
|
|
|
\ 'line': 347,
|
|
|
|
\ 'offset': 12,
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Definition(bufnr(''), 347, 12)
|
2018-04-22 18:49:24 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#References() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'ts@references',
|
|
|
|
\ {
|
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
|
|
|
\ 'line': 347,
|
|
|
|
\ 'offset': 12,
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#References(bufnr(''), 347, 12)
|
2018-04-26 20:54:11 +00:00
|
|
|
|
|
|
|
Execute(ale#lsp#tsserver_message#Quickinfo() should return correct messages):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 0,
|
|
|
|
\ 'ts@quickinfo',
|
|
|
|
\ {
|
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/foo/bar.ts'),
|
|
|
|
\ 'line': 347,
|
|
|
|
\ 'offset': 12,
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#lsp#tsserver_message#Quickinfo(bufnr(''), 347, 12)
|