#392 Handle clang header errors too
This commit is contained in:
parent
b06b832447
commit
65fe914fb8
@ -14,8 +14,12 @@ function! s:AddIncludedErrors(output, include_lnum, include_lines) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:IsHeaderFile(filename) abort
|
||||||
|
return a:filename =~? '\v\.(h|hpp)$'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
|
function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
|
||||||
let l:include_pattern = '\v^(In file included | *)from [^:]*:(\d+)'
|
let l:include_pattern = '\v^(In file included | *)from ([^:]*):(\d+)'
|
||||||
let l:include_lnum = 0
|
let l:include_lnum = 0
|
||||||
let l:include_lines = []
|
let l:include_lines = []
|
||||||
let l:included_filename = ''
|
let l:included_filename = ''
|
||||||
@ -41,9 +45,15 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
|
|||||||
" need to collect it.
|
" need to collect it.
|
||||||
call add(l:include_lines, l:line)
|
call add(l:include_lines, l:line)
|
||||||
else
|
else
|
||||||
" Get the line number out of the parsed include line,
|
" GCC and clang return the lists of files in different orders,
|
||||||
" and reset the other variables.
|
" so we'll only grab the line number from lines which aren't
|
||||||
let l:include_lnum = str2nr(l:include_match[2])
|
" header files.
|
||||||
|
if !s:IsHeaderFile(l:include_match[2])
|
||||||
|
" Get the line number out of the parsed include line,
|
||||||
|
" and reset the other variables.
|
||||||
|
let l:include_lnum = str2nr(l:include_match[3])
|
||||||
|
endif
|
||||||
|
|
||||||
let l:include_lines = []
|
let l:include_lines = []
|
||||||
let l:included_filename = ''
|
let l:included_filename = ''
|
||||||
endif
|
endif
|
||||||
|
23
test/handler/test_clang_handler.vader
Normal file
23
test/handler/test_clang_handler.vader
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Execute(clang errors from included files should be parsed correctly):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 3,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'Problems were found in the header (See :ALEDetail)',
|
||||||
|
\ 'detail': join([
|
||||||
|
\ './b.h:1:1: error: expected identifier or ''(''',
|
||||||
|
\ '{{{',
|
||||||
|
\ '^',
|
||||||
|
\ '1 error generated.',
|
||||||
|
\ ], "\n"),
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale#handlers#gcc#HandleGCCFormat(347, [
|
||||||
|
\ 'In file included from test.c:3:',
|
||||||
|
\ 'In file included from ./a.h:1:',
|
||||||
|
\ './b.h:1:1: error: expected identifier or ''(''',
|
||||||
|
\ '{{{',
|
||||||
|
\ '^',
|
||||||
|
\ '1 error generated.',
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user