2017-07-30 18:53:46 -04:00
|
|
|
Before:
|
|
|
|
let b:project = {
|
|
|
|
\ 'initialized': 0,
|
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2017-07-30 18:53:46 -04:00
|
|
|
\}
|
|
|
|
|
|
|
|
let b:conn = {
|
|
|
|
\ 'projects': {
|
|
|
|
\ '/foo/bar': b:project,
|
|
|
|
\ },
|
2018-07-19 16:15:05 -04:00
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'hover': 0,
|
|
|
|
\ 'references': 0,
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'definition': 0,
|
|
|
|
\ },
|
2017-07-30 18:53:46 -04:00
|
|
|
\}
|
|
|
|
|
|
|
|
After:
|
|
|
|
unlet! b:project
|
|
|
|
unlet! b:conn
|
|
|
|
|
|
|
|
Execute(publishDiagnostics messages with files inside project directories should initialize projects):
|
|
|
|
" This is for some other file, ignore this one.
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'method': 'textDocument/publishDiagnostics',
|
|
|
|
\ 'params': {'uri': 'file:///xyz/bar/baz.txt'},
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'initialized': 0,
|
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2017-07-30 18:53:46 -04:00
|
|
|
\ },
|
|
|
|
\ b:project
|
|
|
|
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'method': 'textDocument/publishDiagnostics',
|
|
|
|
\ 'params': {'uri': 'file:///foo/bar/baz.txt'},
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'initialized': 1,
|
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2017-07-30 18:53:46 -04:00
|
|
|
\ },
|
|
|
|
\ b:project
|
|
|
|
|
|
|
|
Execute(Messages with no method and capabilities should initialize projects):
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'result': {'capabilities': {}},
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'initialized': 1,
|
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2017-07-30 18:53:46 -04:00
|
|
|
\ },
|
|
|
|
\ b:project
|
|
|
|
|
|
|
|
Execute(Other messages should not initialize projects):
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {'method': 'lolwat'})
|
|
|
|
|
|
|
|
AssertEqual 0, b:project.initialized
|
|
|
|
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {'result': {'x': {}}})
|
|
|
|
|
|
|
|
AssertEqual 0, b:project.initialized
|
2018-07-19 16:15:05 -04:00
|
|
|
|
|
|
|
Execute(Capabilities should bet set up correctly):
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'renameProvider': v:true,
|
|
|
|
\ 'executeCommandProvider': {
|
|
|
|
\ 'commands': [],
|
|
|
|
\ },
|
|
|
|
\ 'hoverProvider': v:true,
|
|
|
|
\ 'documentSymbolProvider': v:true,
|
|
|
|
\ 'documentRangeFormattingProvider': v:true,
|
|
|
|
\ 'codeLensProvider': {
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'referencesProvider': v:true,
|
|
|
|
\ 'textDocumentSync': 2,
|
|
|
|
\ 'documentFormattingProvider': v:true,
|
|
|
|
\ 'codeActionProvider': v:true,
|
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'completionProvider': {
|
|
|
|
\ 'triggerCharacters': ['.'],
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': v:true,
|
|
|
|
\ 'experimental': {},
|
|
|
|
\ 'documentHighlightProvider': v:true
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'completion_trigger_characters': ['.'],
|
|
|
|
\ 'completion': 1,
|
|
|
|
\ 'references': 1,
|
|
|
|
\ 'hover': 1,
|
|
|
|
\ 'definition': 1,
|
|
|
|
\ },
|
|
|
|
\ 'message_queue': [],
|
|
|
|
\ 'projects': {
|
|
|
|
\ '/foo/bar': {
|
|
|
|
\ 'initialized': 1,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2018-07-19 16:15:05 -04:00
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ b:conn
|
|
|
|
|
|
|
|
Execute(Disabled capabilities should be recognised correctly):
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'renameProvider': v:true,
|
|
|
|
\ 'executeCommandProvider': {
|
|
|
|
\ 'commands': [],
|
|
|
|
\ },
|
|
|
|
\ 'hoverProvider': v:false,
|
|
|
|
\ 'documentSymbolProvider': v:true,
|
|
|
|
\ 'documentRangeFormattingProvider': v:true,
|
|
|
|
\ 'codeLensProvider': {
|
|
|
|
\ 'resolveProvider': v:false
|
|
|
|
\ },
|
|
|
|
\ 'referencesProvider': v:false,
|
|
|
|
\ 'textDocumentSync': 2,
|
|
|
|
\ 'documentFormattingProvider': v:true,
|
|
|
|
\ 'codeActionProvider': v:true,
|
|
|
|
\ 'signatureHelpProvider': {
|
|
|
|
\ 'triggerCharacters': ['(', ','],
|
|
|
|
\ },
|
|
|
|
\ 'definitionProvider': v:false,
|
|
|
|
\ 'experimental': {},
|
|
|
|
\ 'documentHighlightProvider': v:true
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'capabilities': {
|
|
|
|
\ 'completion_trigger_characters': [],
|
|
|
|
\ 'completion': 0,
|
|
|
|
\ 'references': 0,
|
|
|
|
\ 'hover': 0,
|
|
|
|
\ 'definition': 0,
|
|
|
|
\ },
|
|
|
|
\ 'message_queue': [],
|
|
|
|
\ 'projects': {
|
|
|
|
\ '/foo/bar': {
|
|
|
|
\ 'initialized': 1,
|
|
|
|
\ 'message_queue': [],
|
2018-07-22 14:04:45 -04:00
|
|
|
\ 'capabilities_queue': [],
|
2018-07-19 16:15:05 -04:00
|
|
|
\ 'init_request_id': 3,
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ b:conn
|
2018-08-16 09:19:12 -04:00
|
|
|
|
|
|
|
Execute(Results that are not dictionaries should be handled correctly):
|
|
|
|
call ale#lsp#HandleOtherInitializeResponses(b:conn, {
|
|
|
|
\ 'jsonrpc': '2.0',
|
|
|
|
\ 'id': 1,
|
|
|
|
\ 'result': v:null,
|
|
|
|
\})
|