#852 - Capture error codes for nimcheck
This commit is contained in:
parent
3c8f3221df
commit
c012563984
@ -10,33 +10,40 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
||||
" Only show errors of the current buffer
|
||||
" NOTE: Checking filename only is OK because nim enforces unique
|
||||
" module names.
|
||||
|
||||
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
|
||||
|
||||
if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:line = l:match[2] + 0
|
||||
let l:column = l:match[3] + 0
|
||||
let l:text = l:match[4]
|
||||
let l:type = 'W'
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
|
||||
" Extract error type from message of type 'Error: Some error message'
|
||||
let l:textmatch = matchlist(l:match[4], '^\(.\{-}\): .\+$')
|
||||
let l:error_match = matchlist(l:item.text, '^\(.\{-}\): \(.\+\)$')
|
||||
|
||||
if len(l:textmatch) > 0
|
||||
let l:errortype = l:textmatch[1]
|
||||
if l:errortype is# 'Error'
|
||||
let l:type = 'E'
|
||||
if !empty(l:error_match)
|
||||
if l:error_match[1] is# 'Error'
|
||||
let l:item.type = 'E'
|
||||
let l:item.text = l:error_match[2]
|
||||
elseif l:error_match[1] is# 'Warning'
|
||||
\|| l:error_match[1] is# 'Hint'
|
||||
let l:item.text = l:error_match[2]
|
||||
endif
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:line,
|
||||
\ 'col': l:column,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
let l:code_match = matchlist(l:item.text, '\v^(.+) \[([^ \[]+)\]$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
let l:item.text = l:code_match[1]
|
||||
let l:item.code = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
@ -12,25 +12,27 @@ Execute(Parsing nim errors should work):
|
||||
\ {
|
||||
\ 'lnum': 8,
|
||||
\ 'col': 8,
|
||||
\ 'text': 'Warning: use {.base.} for base methods; baseless methods are deprecated [UseBase]',
|
||||
\ 'text': 'use {.base.} for base methods; baseless methods are deprecated',
|
||||
\ 'code': 'UseBase',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'col': 2,
|
||||
\ 'text': 'Error: identifier expected, but found ''a.barfoo''',
|
||||
\ 'text': 'identifier expected, but found ''a.barfoo''',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 5,
|
||||
\ 'text': 'Hint: ''NotUsed'' is declared but not used [XDeclaredButNotUsed]',
|
||||
\ 'text': '''NotUsed'' is declared but not used',
|
||||
\ 'code': 'XDeclaredButNotUsed',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 12,
|
||||
\ 'col': 2,
|
||||
\ 'text': 'Error: with : character',
|
||||
\ 'text': 'with : character',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
|
Loading…
Reference in New Issue
Block a user