Fix #690 - Filter out errors from other files for Haskell

This commit is contained in:
w0rp
2017-06-25 17:08:57 +01:00
parent 229a1c092a
commit 93473a4101
5 changed files with 44 additions and 12 deletions

View File

@@ -6,10 +6,11 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
"
"Appoint/Lib.hs:8:1: warning:
"Appoint/Lib.hs:8:1:
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\(.*\)\?$'
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$'
let l:output = []
let l:corrected_lines = []
for l:line in a:lines
if len(matchlist(l:line, l:pattern)) > 0
call add(l:corrected_lines, l:line)
@@ -30,21 +31,25 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
continue
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
let l:type = l:errors[1]
let l:text = l:errors[2]
else
let l:type = ''
let l:text = l:match[3]
let l:text = l:match[4]
endif
let l:type = l:type ==# '' ? 'E' : toupper(l:type[0])
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:text,
\ 'type': l:type,
\})

View File

@@ -62,6 +62,23 @@ function! ale#path#IsAbsolute(filename) abort
return a:filename[:0] ==# '/' || a:filename[1:2] ==# ':\'
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
" two paths represent the same file on disk.
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^(\.\.[/\\])+', '/', '')
endif
" Use the basename for files in /tmp, as they are likely our files.
if l:test_filename[:len($TMPDIR) - 1] ==# $TMPDIR
" Use the basename for temporary files, as they are likely our files.
if ale#path#IsTempName(l:test_filename)
let l:test_filename = fnamemodify(l:test_filename, ':t')
endif