Fix #690 - Filter out errors from other files for Haskell
This commit is contained in:
parent
229a1c092a
commit
93473a4101
5 changed files with 44 additions and 12 deletions
|
@ -6,10 +6,11 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
|
||||||
"
|
"
|
||||||
"Appoint/Lib.hs:8:1: warning:
|
"Appoint/Lib.hs:8:1: warning:
|
||||||
"Appoint/Lib.hs:8:1:
|
"Appoint/Lib.hs:8:1:
|
||||||
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\(.*\)\?$'
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
let l:corrected_lines = []
|
let l:corrected_lines = []
|
||||||
|
|
||||||
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)
|
||||||
|
@ -30,21 +31,25 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:errors = matchlist(l:match[3], '\(warning:\|error:\)\(.*\)')
|
if !ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:errors = matchlist(l:match[4], '\(warning:\|error:\)\(.*\)')
|
||||||
|
|
||||||
if len(l:errors) > 0
|
if len(l:errors) > 0
|
||||||
let l:type = l:errors[1]
|
let l:type = l:errors[1]
|
||||||
let l:text = l:errors[2]
|
let l:text = l:errors[2]
|
||||||
else
|
else
|
||||||
let l:type = ''
|
let l:type = ''
|
||||||
let l:text = l:match[3]
|
let l:text = l:match[4]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:type = l:type ==# '' ? 'E' : toupper(l:type[0])
|
let l:type = l:type ==# '' ? 'E' : toupper(l:type[0])
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[3] + 0,
|
||||||
\ 'text': l:text,
|
\ 'text': l:text,
|
||||||
\ 'type': l:type,
|
\ 'type': l:type,
|
||||||
\})
|
\})
|
||||||
|
|
|
@ -62,6 +62,23 @@ function! ale#path#IsAbsolute(filename) abort
|
||||||
return a:filename[:0] ==# '/' || a:filename[1:2] ==# ':\'
|
return a:filename[:0] ==# '/' || a:filename[1:2] ==# ':\'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Given a filename, return 1 if the file represents some temporary file
|
||||||
|
" created by Vim.
|
||||||
|
function! ale#path#IsTempName(filename) abort
|
||||||
|
let l:prefix_list = [
|
||||||
|
\ $TMPDIR,
|
||||||
|
\ '/run/user',
|
||||||
|
\]
|
||||||
|
|
||||||
|
for l:prefix in l:prefix_list
|
||||||
|
if a:filename[:len(l:prefix) - 1] ==# l:prefix
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Given a buffer number and a relative or absolute path, return 1 if the
|
" Given a buffer number and a relative or absolute path, return 1 if the
|
||||||
" two paths represent the same file on disk.
|
" two paths represent the same file on disk.
|
||||||
function! ale#path#IsBufferPath(buffer, complex_filename) abort
|
function! ale#path#IsBufferPath(buffer, complex_filename) abort
|
||||||
|
@ -83,8 +100,8 @@ function! ale#path#IsBufferPath(buffer, complex_filename) abort
|
||||||
let l:test_filename = substitute(l:test_filename, '\v^(\.\.[/\\])+', '/', '')
|
let l:test_filename = substitute(l:test_filename, '\v^(\.\.[/\\])+', '/', '')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Use the basename for files in /tmp, as they are likely our files.
|
" Use the basename for temporary files, as they are likely our files.
|
||||||
if l:test_filename[:len($TMPDIR) - 1] ==# $TMPDIR
|
if ale#path#IsTempName(l:test_filename)
|
||||||
let l:test_filename = fnamemodify(l:test_filename, ':t')
|
let l:test_filename = fnamemodify(l:test_filename, ':t')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Execute(The ghc handler should handle hdevtools output):
|
Execute(The ghc handler should handle hdevtools output):
|
||||||
|
call ale#test#SetFilename('foo.hs')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
|
@ -8,13 +10,15 @@ Execute(The ghc handler should handle hdevtools output):
|
||||||
\ '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]',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(12, [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
\ '/path/to/foo.hs:147:62: warning:',
|
\ 'foo.hs:147:62: warning:',
|
||||||
\ '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’',
|
\ '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’',
|
||||||
\ ' Expected type: [T.Text]',
|
\ ' Expected type: [T.Text]',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
Execute(The ghc handler should handle ghc 8 output):
|
Execute(The ghc handler should handle ghc 8 output):
|
||||||
|
call ale#test#SetFilename('src/Appoint/Lib.hs')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
|
@ -30,7 +34,7 @@ Execute(The ghc handler should handle ghc 8 output):
|
||||||
\ '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.',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(47, [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
\ '',
|
\ '',
|
||||||
\ 'src/Appoint/Lib.hs:6:1: error:',
|
\ 'src/Appoint/Lib.hs:6:1: error:',
|
||||||
\ ' Failed to load interface for ‘GitHub.Data’',
|
\ ' Failed to load interface for ‘GitHub.Data’',
|
||||||
|
@ -42,6 +46,8 @@ Execute(The ghc handler should handle ghc 8 output):
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
Execute(The ghc handler should handle ghc 7 output):
|
Execute(The ghc handler should handle ghc 7 output):
|
||||||
|
call ale#test#SetFilename('src/Main.hs')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
|
@ -51,7 +57,7 @@ Execute(The ghc handler should handle ghc 7 output):
|
||||||
\ 'text': ' parse error (possibly incorrect indentation or mismatched brackets)',
|
\ 'text': ' parse error (possibly incorrect indentation or mismatched brackets)',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(47, [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
\ 'src/Main.hs:168:1:',
|
\ 'src/Main.hs:168:1:',
|
||||||
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Execute(HandleGhcFormat should handle ghc-mod problems):
|
Execute(HandleGhcFormat should handle ghc-mod problems):
|
||||||
|
call ale#test#SetFilename('check2.hs')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
|
@ -21,7 +23,8 @@ Execute(HandleGhcFormat should handle ghc-mod problems):
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [
|
||||||
\ 'check1.hs:2:1:Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.',
|
\ 'check2.hs:2:1:Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.',
|
||||||
\ 'check2.hs:2:1: Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...',
|
\ 'check2.hs:2:1: Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...',
|
||||||
\ 'check2.hs:6:1: Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ',
|
\ 'check2.hs:6:1: Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ',
|
||||||
|
\ 'xxx.hs:6:1: Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
|
@ -41,3 +41,4 @@ Execute(ale#path#IsBufferPath should match files in /tmp):
|
||||||
|
|
||||||
Assert ale#path#IsBufferPath(bufnr(''), '../../../../../../../../tmp/vG0hKyD/1/test.ts')
|
Assert ale#path#IsBufferPath(bufnr(''), '../../../../../../../../tmp/vG0hKyD/1/test.ts')
|
||||||
Assert ale#path#IsBufferPath(bufnr(''), '/tmp/vG0hKyD/1/test.ts')
|
Assert ale#path#IsBufferPath(bufnr(''), '/tmp/vG0hKyD/1/test.ts')
|
||||||
|
Assert ale#path#IsBufferPath(bufnr(''), '/run/user/1000/vG0hKyD/1/test.ts')
|
||||||
|
|
Reference in a new issue