From 75180daad7ce02a0ebdece6aecb77ea698c4f904 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 30 Mar 2017 18:16:38 +0300 Subject: [PATCH] Checker d/dscanner: cleanup. --- autoload/syntastic/preprocess.vim | 44 ++++++++++++++++++++----------- doc/syntastic-checkers.txt | 8 +++--- plugin/syntastic.vim | 2 +- syntax_checkers/d/dscanner.vim | 38 +++++++++++--------------- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/autoload/syntastic/preprocess.vim b/autoload/syntastic/preprocess.vim index 1569bad7..451d308c 100644 --- a/autoload/syntastic/preprocess.vim +++ b/autoload/syntastic/preprocess.vim @@ -98,6 +98,35 @@ function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2 return out endfunction " }}}2 +function! syntastic#preprocess#dscanner(errors) abort " {{{2 + let idx = 0 + while idx < len(a:errors) && a:errors[idx][0] !=# '{' + let idx += 1 + endwhile + let errs = s:_decode_JSON(join(a:errors[idx :], '')) + + let out = [] + if type(errs) == type({}) && has_key(errs, 'issues') && type(errs['issues']) == type([]) + for issue in errs['issues'] + try + call add(out, + \ issue['fileName'] . ':' . + \ issue['line'] . ':' . + \ issue['column'] . ':' . + \ issue['message'] . ' [' . issue['key'] . ']') + catch /\m^Vim\%((\a\+)\)\=:E716/ + call syntastic#log#warn('checker d/dscanner: unrecognized error item ' . string(issue)) + let out = [] + break + endtry + endfor + else + call syntastic#log#warn('checker d/dscanner: unrecognized error format (crashed checker?)') + endif + + return out +endfunction " }}}2 + function! syntastic#preprocess#flow(errors) abort " {{{2 let idx = 0 while idx < len(a:errors) && a:errors[idx][0] !=# '{' @@ -424,21 +453,6 @@ function! syntastic#preprocess#validator(errors) abort " {{{2 return out endfunction " }}}2 -function! syntastic#preprocess#dscanner(errors) abort " {{{2 - let startIndex = index(a:errors, '{') - let data = join(a:errors[startIndex:], '') - let errs = s:_decode_JSON(data) - - let out = [] - let issues = errs['issues'] - for issue in issues - let msg = issue['fileName'] . ':' . issue['line'] . ':' - \ . issue['column'] . ':' . issue['message'] - call add(out, msg) - endfor - return out -endfunction " }}}2 - function! syntastic#preprocess#vint(errors) abort " {{{2 let errs = s:_decode_JSON(join(a:errors, '')) diff --git a/doc/syntastic-checkers.txt b/doc/syntastic-checkers.txt index 791fd902..7c902f9a 100644 --- a/doc/syntastic-checkers.txt +++ b/doc/syntastic-checkers.txt @@ -1755,7 +1755,7 @@ SYNTAX CHECKERS FOR D *syntastic-checkers-d* The following checkers are available for D (filetype "d"): 1. DMD......................|syntastic-d-dmd| - 1. D-Scanner................|syntastic-d-dscanner| + 2. D-Scanner................|syntastic-d-dscanner| ------------------------------------------------------------------------------ 1. DMD *syntastic-d-dmd* @@ -1836,13 +1836,13 @@ the usual 'g:syntastic_d_dmd_