Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 8c05dbf

Browse files
committed
A first attempt at checking the exit code from the checkers.
1 parent 3e46bcf commit 8c05dbf

13 files changed

Lines changed: 43 additions & 9 deletions

File tree

autoload/syntastic/util.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,16 @@ function! syntastic#util#info(msg)
175175
endfunction
176176

177177
function! syntastic#util#warn(msg)
178+
echohl WarningMsg
178179
echomsg "syntastic: warning: " . a:msg
180+
echohl None
181+
endfunction
182+
183+
function! syntastic#util#error(msg)
184+
execute "normal \<Esc>"
185+
echohl ErrorMsg
186+
echomsg "syntastic: error: " . a:msg
187+
echohl None
179188
endfunction
180189

181190
function! syntastic#util#deprecationWarn(msg)

plugin/syntastic.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ endfunction
327327
" 'subtype' - all errors will be assigned the given subtype
328328
" 'postprocess' - a list of functions to be applied to the error list
329329
" 'cwd' - change directory to the given path before running the checker
330+
" 'returns' - a list of valid exit codes for the checker
330331
function! SyntasticMake(options)
331332
call syntastic#util#debug('SyntasticMake: called with options: '. string(a:options))
332333

@@ -377,6 +378,10 @@ function! SyntasticMake(options)
377378
call s:Redraw()
378379
endif
379380

381+
if has_key(a:options, 'returns') && index(a:options['returns'], v:shell_error) == -1
382+
throw 'Syntastic: checker error'
383+
endif
384+
380385
if has_key(a:options, 'defaults')
381386
call SyntasticAddToErrors(errors, a:options['defaults'])
382387
endif

plugin/syntastic/checker.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ function! g:SyntasticChecker.getName()
3636
endfunction
3737

3838
function! g:SyntasticChecker.getLocList()
39-
let list = self._locListFunc()
40-
call syntastic#util#debug('getLocList: checker ' . self._filetype . '/' . self._name . ' returned ' . v:shell_error)
39+
try
40+
let list = self._locListFunc()
41+
call syntastic#util#debug('getLocList: checker ' . self._filetype . '/' . self._name . ' returned ' . v:shell_error)
42+
catch /\m\C^Syntastic: checker error$/
43+
let list = []
44+
call syntastic#util#error('checker ' . self._filetype . '/' . self._name . ' returned abnormal status ' . v:shell_error)
45+
endtry
4146
call self._populateHighlightRegexes(list)
4247
return g:SyntasticLoclist.New(list)
4348
endfunction

syntax_checkers/c/checkpatch.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function! SyntaxCheckers_c_checkpatch_GetLocList()
3939
return SyntasticMake({
4040
\ 'makeprg': makeprg,
4141
\ 'errorformat': errorformat,
42+
\ 'returns': [0],
4243
\ 'subtype': 'Style' })
4344
endfunction
4445

syntax_checkers/c/sparse.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function! SyntaxCheckers_c_sparse_GetLocList()
4141
let loclist = SyntasticMake({
4242
\ 'makeprg': makeprg,
4343
\ 'errorformat': errorformat,
44-
\ 'defaults': {'bufnr': bufnr("")} })
44+
\ 'defaults': {'bufnr': bufnr("")},
45+
\ 'returns': [0] })
4546
return loclist
4647
endfunction
4748

syntax_checkers/html/tidy.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function! SyntaxCheckers_html_tidy_GetLocList()
9797
let loclist = SyntasticMake({
9898
\ 'makeprg': makeprg,
9999
\ 'errorformat': errorformat,
100-
\ 'defaults': {'bufnr': bufnr("")} })
100+
\ 'defaults': {'bufnr': bufnr("")},
101+
\ 'returns': [0, 1, 2] })
101102

102103
" filter out valid HTML5 from the errors
103104
for n in range(len(loclist))

syntax_checkers/html/w3.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function! SyntaxCheckers_html_w3_GetLocList()
3434
let makeprg = 'curl -s -F output=json ' .
3535
\ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' .
3636
\ g:syntastic_html_w3_api
37+
3738
let errorformat =
3839
\ '%A %\+{,' .
3940
\ '%C %\+"lastLine": %l\,%\?,' .
@@ -44,7 +45,12 @@ function! SyntaxCheckers_html_w3_GetLocList()
4445
\ '%C %\+"subtype": "%tarning"\,%\?,' .
4546
\ '%Z %\+}\,,' .
4647
\ '%-G%.%#'
47-
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
48+
49+
let loclist = SyntasticMake({
50+
\ 'makeprg': makeprg,
51+
\ 'errorformat': errorformat,
52+
\ 'defaults': {'bufnr': bufnr("")},
53+
\ 'returns': [0] })
4854

4955
for n in range(len(loclist))
5056
let loclist[n]['text'] = substitute(loclist[n]['text'], '\\\([\"]\)', '\1', 'g')

syntax_checkers/nroff/mandoc.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function! SyntaxCheckers_nroff_mandoc_GetLocList()
3131

3232
return SyntasticMake({
3333
\ 'makeprg': makeprg,
34-
\ 'errorformat': errorformat })
34+
\ 'errorformat': errorformat,
35+
\ 'returns': [0, 2, 3, 4] })
3536
endfunction
3637

3738
call g:SyntasticRegistry.CreateAndRegisterChecker({

syntax_checkers/perl/perlcritic.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function! SyntaxCheckers_perl_perlcritic_GetLocList()
4949
let loclist = SyntasticMake({
5050
\ 'makeprg': makeprg,
5151
\ 'errorformat': errorformat,
52+
\ 'returns': [0, 2],
5253
\ 'subtype': 'Style' })
5354

5455
" change error types according to the prescribed threshold

syntax_checkers/pod/podchecker.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function! SyntaxCheckers_pod_podchecker_GetLocList()
3232

3333
let loclist = SyntasticMake({
3434
\ 'makeprg': makeprg,
35-
\ 'errorformat': errorformat })
35+
\ 'errorformat': errorformat,
36+
\ 'returns': [0, 1, 2] })
3637

3738
for n in range(len(loclist))
3839
let e = loclist[n]

0 commit comments

Comments
 (0)