Fix #536 - Implement linter problem type re-mapping

This commit is contained in:
w0rp
2017-06-14 17:59:13 +01:00
parent c2258e3684
commit f814be45b1
4 changed files with 180 additions and 0 deletions

View File

@@ -257,6 +257,28 @@ function! ale#engine#SetResults(buffer, loclist) abort
endif
endfunction
function! s:RemapItemTypes(type_map, loclist) abort
for l:item in a:loclist
let l:key = l:item.type
\ . (get(l:item, 'sub_type', '') ==# 'style' ? 'S' : '')
let l:new_key = get(a:type_map, l:key, '')
if l:new_key ==# 'E'
\|| l:new_key ==# 'ES'
\|| l:new_key ==# 'W'
\|| l:new_key ==# 'WS'
\|| l:new_key ==# 'I'
let l:item.type = l:new_key[0]
if l:new_key ==# 'ES' || l:new_key ==# 'WS'
let l:item.sub_type = 'style'
elseif has_key(l:item, 'sub_type')
call remove(l:item, 'sub_type')
endif
endif
endfor
endfunction
function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
let l:new_loclist = []
@@ -317,6 +339,12 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
call add(l:new_loclist, l:item)
endfor
let l:type_map = get(ale#Var(a:buffer, 'type_map'), a:linter_name, {})
if !empty(l:type_map)
call s:RemapItemTypes(l:type_map, l:new_loclist)
endif
return l:new_loclist
endfunction