Fix #918 - Save prettier details for Haskell linters
This commit is contained in:
parent
8254e507d6
commit
ae7cd2c090
@ -24,20 +24,25 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
|
|||||||
|
|
||||||
let l:corrected_lines = []
|
let l:corrected_lines = []
|
||||||
|
|
||||||
|
" Group the lines into smaller lists.
|
||||||
for l:line in a:lines
|
for l:line in a:lines
|
||||||
if len(matchlist(l:line, l:pattern)) > 0
|
if len(matchlist(l:line, l:pattern)) > 0
|
||||||
call add(l:corrected_lines, l:line)
|
call add(l:corrected_lines, [l:line])
|
||||||
elseif l:line is# ''
|
elseif l:line is# ''
|
||||||
call add(l:corrected_lines, l:line)
|
call add(l:corrected_lines, [l:line])
|
||||||
else
|
elseif len(l:corrected_lines) > 0
|
||||||
if len(l:corrected_lines) > 0
|
call add(l:corrected_lines[-1], l:line)
|
||||||
let l:line = substitute(l:line, '\v^\s+', ' ', '')
|
|
||||||
let l:corrected_lines[-1] .= l:line
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for l:line in l:corrected_lines
|
for l:line_list in l:corrected_lines
|
||||||
|
" Join the smaller lists into one large line to parse.
|
||||||
|
let l:line = l:line_list[0]
|
||||||
|
|
||||||
|
for l:extra_line in l:line_list[1:]
|
||||||
|
let l:line .= substitute(l:extra_line, '\v^\s+', ' ', '')
|
||||||
|
endfor
|
||||||
|
|
||||||
let l:match = matchlist(l:line, l:pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
@ -67,12 +72,19 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
|
|||||||
" Replace temporary filenames in problem messages with the basename
|
" Replace temporary filenames in problem messages with the basename
|
||||||
let l:text = substitute(l:text, l:temp_filename_regex, l:basename, 'g')
|
let l:text = substitute(l:text, l:temp_filename_regex, l:basename, 'g')
|
||||||
|
|
||||||
call add(l:output, {
|
let l:item = {
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'col': l:match[3] + 0,
|
\ 'col': l:match[3] + 0,
|
||||||
\ 'text': l:text,
|
\ 'text': l:text,
|
||||||
\ 'type': l:type,
|
\ 'type': l:type,
|
||||||
\})
|
\}
|
||||||
|
|
||||||
|
" Include extra lines as details if they are there.
|
||||||
|
if len(l:line_list) > 1
|
||||||
|
let l:item.detail = join(l:line_list[1:], "\n")
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, l:item)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
|
@ -8,6 +8,10 @@ Execute(The ghc handler should handle hdevtools output):
|
|||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'col': 62,
|
\ 'col': 62,
|
||||||
\ 'text': '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’ Expected type: [T.Text]',
|
\ 'text': '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’ Expected type: [T.Text]',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’',
|
||||||
|
\ ' Expected type: [T.Text]',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
@ -26,12 +30,20 @@ Execute(The ghc handler should handle ghc 8 output):
|
|||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'text': 'Failed to load interface for ‘GitHub.Data’ Use -v to see a list of the files searched for.',
|
\ 'text': 'Failed to load interface for ‘GitHub.Data’ Use -v to see a list of the files searched for.',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' Failed to load interface for ‘GitHub.Data’',
|
||||||
|
\ ' Use -v to see a list of the files searched for.',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 7,
|
\ 'lnum': 7,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'text': 'Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.',
|
\ 'text': 'Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' Failed to load interface for ‘GitHub.Endpoints.PullRequests’',
|
||||||
|
\ ' Use -v to see a list of the files searched for.',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
@ -55,24 +67,36 @@ Execute(The ghc handler should handle ghc 7 output):
|
|||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'text': 'parse error (possibly incorrect indentation or mismatched brackets)',
|
\ 'text': 'parse error (possibly incorrect indentation or mismatched brackets)',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 84,
|
\ 'lnum': 84,
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'text': 'Top-level binding with no type signature:^@ myLayout :: Choose Tall (Choose (Mirror Tall) Full) a',
|
\ 'text': 'Top-level binding with no type signature: myLayout :: Choose Tall (Choose (Mirror Tall) Full) a',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' Top-level binding with no type signature:',
|
||||||
|
\ ' myLayout :: Choose Tall (Choose (Mirror Tall) Full) a',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 94,
|
\ 'lnum': 94,
|
||||||
\ 'col': 5,
|
\ 'col': 5,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': 'Some other error',
|
\ 'text': 'Some other error',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' Some other error',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
\ ale#path#Winify('src/Main.hs') . ':168:1:',
|
\ ale#path#Winify('src/Main.hs') . ':168:1:',
|
||||||
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
||||||
\ ale#path#Winify('src/Main.hs') . ':84:1:Warning: Top-level binding with no type signature:^@ myLayout :: Choose Tall (Choose (Mirror Tall) Full) a',
|
\ ale#path#Winify('src/Main.hs') . ':84:1:Warning:',
|
||||||
|
\ ' Top-level binding with no type signature:',
|
||||||
|
\ ' myLayout :: Choose Tall (Choose (Mirror Tall) Full) a',
|
||||||
\ ale#path#Winify('src/Main.hs') . ':94:5:Error:',
|
\ ale#path#Winify('src/Main.hs') . ':94:5:Error:',
|
||||||
\ ' Some other error',
|
\ ' Some other error',
|
||||||
\ ])
|
\ ])
|
||||||
@ -87,6 +111,14 @@ Execute(The ghc handler should handle stack 1.5.1 output):
|
|||||||
\ 'col': 14,
|
\ 'col': 14,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': '• Expecting one fewer arguments to ‘Exp’ Expected kind ‘k0 -> *’, but ‘Exp’ has kind ‘*’ • In the type ‘Exp a’ | 160 | pattern F :: Exp a | ^^^^^',
|
\ 'text': '• Expecting one fewer arguments to ‘Exp’ Expected kind ‘k0 -> *’, but ‘Exp’ has kind ‘*’ • In the type ‘Exp a’ | 160 | pattern F :: Exp a | ^^^^^',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ ' • Expecting one fewer arguments to ‘Exp’',
|
||||||
|
\ ' Expected kind ‘k0 -> *’, but ‘Exp’ has kind ‘*’',
|
||||||
|
\ ' • In the type ‘Exp a’',
|
||||||
|
\ ' |',
|
||||||
|
\ ' 160 | pattern F :: Exp a',
|
||||||
|
\ ' | ^^^^^',
|
||||||
|
\ ], "\n"),
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
|
Loading…
Reference in New Issue
Block a user