2017-05-08 17:18:28 -04:00
Before:
function Range(start_line, start_char, end_line, end_char) abort
return {
\ 'start': {'line': a:start_line, 'character': a:start_char},
\ 'end': {'line': a:end_line, 'character': a:end_char},
\}
endfunction
After:
delfunction Range
Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
2017-07-26 05:37:37 -04:00
AssertEqual [
2017-05-08 17:18:28 -04:00
\ {
\ 'type': 'E',
2017-06-08 12:28:38 -04:00
\ 'text': 'Something went wrong!',
2017-05-08 17:18:28 -04:00
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
2019-01-21 10:36:52 -05:00
\ 'end_col': 15,
2018-07-30 18:19:59 -04:00
\ 'code': 'some-error',
2017-05-08 17:18:28 -04:00
\ }
2017-07-26 05:37:37 -04:00
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
2017-05-08 17:18:28 -04:00
\ {
\ 'severity': 1,
\ 'range': Range(2, 10, 4, 15),
\ 'code': 'some-error',
\ 'message': 'Something went wrong!',
\ },
2017-07-26 05:37:37 -04:00
\ ]}})
2017-05-08 17:18:28 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
2017-07-26 05:37:37 -04:00
AssertEqual [
2017-05-08 17:18:28 -04:00
\ {
\ 'type': 'W',
2017-06-08 12:28:38 -04:00
\ 'text': 'Something went wrong!',
2017-05-08 17:18:28 -04:00
\ 'lnum': 2,
\ 'col': 4,
\ 'end_lnum': 2,
2019-01-21 10:36:52 -05:00
\ 'end_col': 3,
2018-07-30 18:19:59 -04:00
\ 'code': 'some-warning',
2017-05-08 17:18:28 -04:00
\ }
2017-07-26 05:37:37 -04:00
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
2017-05-08 17:18:28 -04:00
\ {
\ 'severity': 2,
\ 'range': Range(1, 3, 1, 3),
\ 'code': 'some-warning',
\ 'message': 'Something went wrong!',
\ },
2017-07-26 05:37:37 -04:00
\ ]}})
2017-05-08 17:18:28 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing severity as errors):
2017-07-26 05:37:37 -04:00
AssertEqual [
2017-05-08 17:18:28 -04:00
\ {
\ 'type': 'E',
2017-06-08 12:28:38 -04:00
\ 'text': 'Something went wrong!',
2017-05-08 17:18:28 -04:00
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
2019-01-21 10:36:52 -05:00
\ 'end_col': 15,
2018-07-30 18:19:59 -04:00
\ 'code': 'some-error',
2017-05-08 17:18:28 -04:00
\ }
2017-07-26 05:37:37 -04:00
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
2017-05-08 17:18:28 -04:00
\ {
\ 'range': Range(2, 10, 4, 15),
\ 'code': 'some-error',
\ 'message': 'Something went wrong!',
\ },
2017-07-26 05:37:37 -04:00
\ ]}})
2017-05-08 17:18:28 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes):
2017-07-26 05:37:37 -04:00
AssertEqual [
2017-05-08 17:18:28 -04:00
\ {
\ 'type': 'E',
2017-06-08 12:28:38 -04:00
\ 'text': 'Something went wrong!',
2017-05-08 17:18:28 -04:00
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
2019-01-21 10:36:52 -05:00
\ 'end_col': 15,
2017-05-08 17:18:28 -04:00
\ }
2017-07-26 05:37:37 -04:00
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
2017-05-08 17:18:28 -04:00
\ {
\ 'range': Range(2, 10, 4, 15),
\ 'message': 'Something went wrong!',
\ },
2017-07-26 05:37:37 -04:00
\ ]}})
2017-05-08 17:18:28 -04:00
2018-11-29 16:51:01 -05:00
Execute(ale#lsp#response#ReadDiagnostics() should include sources in detail):
AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
\ 'detail': '[tslint] Something went wrong!',
\ 'lnum': 10,
\ 'col': 15,
\ 'end_lnum': 12,
2019-01-21 10:36:52 -05:00
\ 'end_col': 22,
2018-11-29 16:51:01 -05:00
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(9, 14, 11, 22),
\ 'message': 'Something went wrong!',
\ 'source': 'tslint',
\ }
\ ]}})
2018-08-02 12:30:22 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code):
AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
2019-01-21 10:36:52 -05:00
\ 'end_col': 15,
2018-08-02 12:30:22 -04:00
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(2, 10, 4, 15),
\ 'message': 'Something went wrong!',
\ 'code': -1,
\ },
\ ]}})
2017-05-08 17:18:28 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
2017-07-26 05:37:37 -04:00
AssertEqual [
2017-05-08 17:18:28 -04:00
\ {
\ 'type': 'E',
2017-06-08 12:28:38 -04:00
\ 'text': 'Something went wrong!',
2017-05-08 17:18:28 -04:00
\ 'lnum': 1,
\ 'col': 3,
\ 'end_lnum': 1,
2019-01-21 10:36:52 -05:00
\ 'end_col': 2,
2017-05-08 17:18:28 -04:00
\ },
\ {
\ 'type': 'W',
2017-06-08 12:28:38 -04:00
\ 'text': 'A warning',
2017-05-08 17:18:28 -04:00
\ 'lnum': 2,
\ 'col': 5,
\ 'end_lnum': 2,
2019-01-21 10:36:52 -05:00
\ 'end_col': 4,
2017-05-08 17:18:28 -04:00
\ },
2017-07-26 05:37:37 -04:00
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
2017-05-08 17:18:28 -04:00
\ {
\ 'range': Range(0, 2, 0, 2),
\ 'message': 'Something went wrong!',
\ },
\ {
\ 'severity': 2,
\ 'range': Range(1, 4, 1, 4),
\ 'message': 'A warning',
\ },
2017-07-26 05:37:37 -04:00
\ ]}})
2017-06-08 12:28:38 -04:00
2018-08-15 17:19:32 -04:00
Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for detail):
AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
\ 'lnum': 1,
\ 'col': 3,
\ 'end_lnum': 1,
2019-01-21 10:36:52 -05:00
\ 'end_col': 2,
2018-08-15 17:46:57 -04:00
\ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:43:80:\n\tmight be this"
2018-08-15 17:40:51 -04:00
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(0, 2, 0, 2),
\ 'message': 'Something went wrong!',
2018-08-15 17:19:32 -04:00
\ 'relatedInformation': [{
\ 'message': 'might be this',
\ 'location': {
\ 'uri': 'file:///tmp/someotherfile.txt',
\ 'range': {
\ 'start': { 'line': 42, 'character': 79 },
2018-08-15 17:46:57 -04:00
\ 'end': { 'line': 142, 'character': 179},
2018-08-15 17:19:32 -04:00
\ }
\ }
\ }]
\ }
\ ]}})
2017-06-08 12:28:38 -04:00
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
2018-03-02 15:33:45 -05:00
AssertEqual
\ [
2017-06-08 12:28:38 -04:00
\ {
\ 'type': 'E',
\ 'nr': 2365,
2018-07-30 18:19:59 -04:00
\ 'code': '2365',
2017-06-08 12:28:38 -04:00
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
\ 'lnum': 1,
\ 'col': 11,
\ 'end_lnum': 1,
\ 'end_col': 17,
\ },
2018-03-02 15:33:45 -05:00
\ ],
2017-06-08 12:28:38 -04:00
\ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/bar/foo.ts","diagnostics":[{"start":{"line":1,"offset":11},"end":{"line":1,"offset":17},"text":"Operator ''+'' cannot be applied to types ''3'' and ''{}''.","code":2365}]}})
2018-03-02 15:33:45 -05:00
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from tsserver):
AssertEqual
\ [
\ {
\ 'lnum': 27,
\ 'col': 3,
\ 'nr': 2515,
2018-07-30 18:19:59 -04:00
\ 'code': '2515',
2018-03-02 15:33:45 -05:00
\ 'end_lnum': 27,
\ 'type': 'W',
\ 'end_col': 14,
\ 'text': 'Calls to ''console.log'' are not allowed. (no-console)',
\ }
\ ],
\ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Calls to 'console.log' are not allowed. (no-console)","code":2515,"category":"warning","source":"tslint"}]}})
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions from tsserver):
AssertEqual
\ [
\ {
\ 'lnum': 27,
\ 'col': 3,
\ 'nr': 2515,
2018-07-30 18:19:59 -04:00
\ 'code': '2515',
2018-03-02 15:33:45 -05:00
\ 'end_lnum': 27,
\ 'type': 'I',
\ 'end_col': 14,
\ 'text': 'Some info',
\ }
\ ],
\ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Some info","code":2515,"category":"suggestion","source":"tslint"}]}})