Use message as text instead of title

`title` does not contain much information which forces to use :ALEDetail most of the time
This commit is contained in:
Héctor Ramón Jiménez 2018-05-12 04:16:14 +02:00
parent 089a07c6a6
commit c3f61c391b
2 changed files with 48 additions and 29 deletions

View File

@ -20,21 +20,30 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
if l:report.type is? 'error'
" General problem
let l:details = map(copy(l:report.message), 'ale_linters#elm#make#ParseMessageItem(v:val)')
let l:details = ale_linters#elm#make#ParseMessage(l:report.message)
if ale_linters#elm#make#FileIsBuffer(l:report.path)
call add(l:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:report.title,
\ 'detail': join(l:details, '')
\ 'text': l:details,
\})
else
call add(l:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:report.path .' - '. l:details,
\ 'detail': l:report.path ." ----------\n\n". l:details,
\})
endif
else
" Compilation errors
for l:error in l:report.errors
let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path)
for l:problem in l:error.problems
let l:details = map(copy(l:problem.message), 'ale_linters#elm#make#ParseMessageItem(v:val)')
let l:details = ale_linters#elm#make#ParseMessage(l:problem.message)
if l:file_is_buffer
" Buffer module has problems
@ -44,8 +53,7 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
\ 'end_lnum': l:problem.region.end.line,
\ 'end_col': l:problem.region.end.column,
\ 'type': 'E',
\ 'text': l:problem.title,
\ 'detail': join(l:details, '')
\ 'text': l:details,
\})
else
" Imported module has problems
@ -53,8 +61,8 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
call add(l:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:location .' - '. l:problem.title,
\ 'detail': l:location ." -------\n\n" . join(l:details, '')
\ 'text': l:location .' - '. l:details,
\ 'detail': l:location ." ----------\n\n". l:details,
\})
endif
endfor
@ -88,6 +96,10 @@ function! ale_linters#elm#make#FileIsBuffer(path) abort
endif
endfunction
function! ale_linters#elm#make#ParseMessage(message) abort
return join(map(copy(a:message), 'ale_linters#elm#make#ParseMessageItem(v:val)'), '')
endfunction
function! ale_linters#elm#make#ParseMessageItem(item) abort
if type(a:item) == type('')
return a:item

View File

@ -15,8 +15,7 @@ Execute(The elm make handler should parse general problems correctly):
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'UNKNOWN IMPORT',
\ 'detail': "error details 1\n\nstyled details"
\ 'text': "error details\n\nstyled details"
\ }
\ ],
\ ale_linters#elm#make#Handle(347, [
@ -24,7 +23,7 @@ Execute(The elm make handler should parse general problems correctly):
\ "type": "error",
\ "path": "' . b:tmp . '/Module.elm",
\ "title": "UNKNOWN IMPORT",
\ "message": ["error details 1\n\n", { "string": "styled details" }]
\ "message": ["error details\n\n", { "string": "styled details" }]
\ }'
\ ])
@ -37,8 +36,7 @@ Execute(The elm make handler should parse compilation errors correctly):
\ 'end_lnum': 408,
\ 'end_col': 18,
\ 'type': 'E',
\ 'text': 'TYPE MISMATCH',
\ 'detail': "error details 1\n\nstyled details"
\ 'text': "error details 1\n\nstyled details"
\ },
\ {
\ 'lnum': 406,
@ -46,8 +44,7 @@ Execute(The elm make handler should parse compilation errors correctly):
\ 'end_lnum': 407,
\ 'end_col': 17,
\ 'type': 'E',
\ 'text': 'TYPE MISMATCH',
\ 'detail': "error details 2",
\ 'text': "error details 2",
\ },
\ {
\ 'lnum': 406,
@ -55,8 +52,7 @@ Execute(The elm make handler should parse compilation errors correctly):
\ 'end_lnum': 406,
\ 'end_col': 93,
\ 'type': 'E',
\ 'text': 'TYPE MISMATCH',
\ 'detail': "error details 3",
\ 'text': "error details 3",
\ },
\ ],
\ ale_linters#elm#make#Handle(347, [
@ -87,18 +83,30 @@ Execute(The elm make handler should parse compilation errors correctly):
\ }'
\ ])
Execute(The elm make handler should put an error on the first line for compilation errors in imported modules):
Execute(The elm make handler should handle errors in imported modules):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'src/Module.elm:404 - TYPE MISMATCH',
\ 'detail': "src/Module.elm:404 -------\n\nerror details\n\nstyled details"
\ 'text': "src/Module.elm - error details\n\nstyled details",
\ 'detail': "src/Module.elm ----------\n\nerror details\n\nstyled details"
\ },
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': "src/Module.elm:404 - error details\n\nstyled details",
\ 'detail': "src/Module.elm:404 ----------\n\nerror details\n\nstyled details"
\ },
\ ],
\ ale_linters#elm#make#Handle(347, [
\ '{
\ "type": "error",
\ "path": "src/Module.elm",
\ "title": "UNKNOWN IMPORT",
\ "message": ["error details\n\n", { "string": "styled details" }]
\ }',
\ '{
\ "type": "compile-errors",
\ "errors": [
\ {
@ -124,8 +132,7 @@ Execute(The elm make handler should put an error on the first line if a line can
\ 'end_lnum': 408,
\ 'end_col': 18,
\ 'type': 'E',
\ 'text': 'TYPE MISMATCH',
\ 'detail': "error details 1 styled details"
\ 'text': "error details 1\n\nstyled details"
\ },
\ {
\ 'lnum': 1,
@ -143,13 +150,13 @@ Execute(The elm make handler should put an error on the first line if a line can
\ "problems": [
\ {
\ "title": "TYPE MISMATCH",
\ "message": ["error details 1 ", { "string": "styled details" }],
\ "message": ["error details 1\n\n", { "string": "styled details" }],
\ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
\ }
\ ]
\ }
\ ]
\ }',
\ "Not JSON",
\ "Also not JSON",
\ 'Not JSON',
\ 'Also not JSON',
\ ])