mirror of
https://github.com/dense-analysis/ale
synced 2024-12-29 09:32:29 +00:00
136 lines
3.6 KiB
Plaintext
136 lines
3.6 KiB
Plaintext
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):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'E',
|
|
\ 'text': 'Something went wrong!',
|
|
\ 'lnum': 3,
|
|
\ 'col': 11,
|
|
\ 'end_lnum': 5,
|
|
\ 'end_col': 16,
|
|
\ 'nr': 'some-error',
|
|
\ }
|
|
\ ],
|
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
|
\ {
|
|
\ 'severity': 1,
|
|
\ 'range': Range(2, 10, 4, 15),
|
|
\ 'code': 'some-error',
|
|
\ 'message': 'Something went wrong!',
|
|
\ },
|
|
\ ]}})
|
|
|
|
Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'W',
|
|
\ 'text': 'Something went wrong!',
|
|
\ 'lnum': 2,
|
|
\ 'col': 4,
|
|
\ 'end_lnum': 2,
|
|
\ 'end_col': 4,
|
|
\ 'nr': 'some-warning',
|
|
\ }
|
|
\ ],
|
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
|
\ {
|
|
\ 'severity': 2,
|
|
\ 'range': Range(1, 3, 1, 3),
|
|
\ 'code': 'some-warning',
|
|
\ 'message': 'Something went wrong!',
|
|
\ },
|
|
\ ]}})
|
|
|
|
Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing severity as errors):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'E',
|
|
\ 'text': 'Something went wrong!',
|
|
\ 'lnum': 3,
|
|
\ 'col': 11,
|
|
\ 'end_lnum': 5,
|
|
\ 'end_col': 16,
|
|
\ 'nr': 'some-error',
|
|
\ }
|
|
\ ],
|
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
|
\ {
|
|
\ 'range': Range(2, 10, 4, 15),
|
|
\ 'code': 'some-error',
|
|
\ 'message': 'Something went wrong!',
|
|
\ },
|
|
\ ]}})
|
|
|
|
Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'E',
|
|
\ 'text': 'Something went wrong!',
|
|
\ 'lnum': 3,
|
|
\ 'col': 11,
|
|
\ 'end_lnum': 5,
|
|
\ 'end_col': 16,
|
|
\ }
|
|
\ ],
|
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
|
\ {
|
|
\ 'range': Range(2, 10, 4, 15),
|
|
\ 'message': 'Something went wrong!',
|
|
\ },
|
|
\ ]}})
|
|
|
|
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'E',
|
|
\ 'text': 'Something went wrong!',
|
|
\ 'lnum': 1,
|
|
\ 'col': 3,
|
|
\ 'end_lnum': 1,
|
|
\ 'end_col': 3,
|
|
\ },
|
|
\ {
|
|
\ 'type': 'W',
|
|
\ 'text': 'A warning',
|
|
\ 'lnum': 2,
|
|
\ 'col': 5,
|
|
\ 'end_lnum': 2,
|
|
\ 'end_col': 5,
|
|
\ },
|
|
\ ],
|
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
|
\ {
|
|
\ 'range': Range(0, 2, 0, 2),
|
|
\ 'message': 'Something went wrong!',
|
|
\ },
|
|
\ {
|
|
\ 'severity': 2,
|
|
\ 'range': Range(1, 4, 1, 4),
|
|
\ 'message': 'A warning',
|
|
\ },
|
|
\ ]}})
|
|
|
|
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
|
|
AssertEqual [
|
|
\ {
|
|
\ 'type': 'E',
|
|
\ 'nr': 2365,
|
|
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
|
|
\ 'lnum': 1,
|
|
\ 'col': 11,
|
|
\ 'end_lnum': 1,
|
|
\ 'end_col': 17,
|
|
\ },
|
|
\],
|
|
\ 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}]}})
|