Go checker: more contortions around "go_go_build_args" and "go_go_test_args".

This commit is contained in:
LCD 47 2015-01-15 17:51:15 +02:00
parent 8b97caa2d9
commit c60e440d00
3 changed files with 20 additions and 15 deletions

View File

@ -264,6 +264,17 @@ function! syntastic#util#shexpand(string, ...) " {{{2
return syntastic#util#shescape(a:0 ? expand(a:string, a:1) : expand(a:string, 1))
endfunction " }}}2
" Escape arguments
function! syntastic#util#argsescape(opt) " {{{2
if type(a:opt) == type('') && a:opt != ''
return [a:opt]
elseif type(a:opt) == type([])
return map(copy(a:opt), 'syntastic#util#shescape(v:val)')
endif
return []
endfunction " }}}2
" decode XML entities
function! syntastic#util#decodeXMLEntities(string) " {{{2
let str = a:string

View File

@ -162,23 +162,13 @@ endfunction " }}}2
function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2
let ret = []
call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, self._shescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) )
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, syntastic#util#argsescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) )
call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_after', '')) )
return ret
endfunction " }}}2
function! g:SyntasticChecker._shescape(opt) " {{{2
if type(a:opt) == type('') && a:opt != ''
return [a:opt]
elseif type(a:opt) == type([])
return map(copy(a:opt), 'syntastic#util#shescape(v:val)')
endif
return []
endfunction " }}}2
" }}}1
" Private functions {{{1

View File

@ -51,12 +51,16 @@ function! SyntaxCheckers_go_go_GetLocList() dict
" compiled by `go build`, therefore `go test` must be called for those.
if match(expand('%', 1), '\m_test\.go$') == -1
let opts = syntastic#util#var('go_go_build_args')
let opts = opts != '' ? syntastic#util#shescape(opts) : ''
if type(opts) != type('') || opts != ''
let opts = join(syntastic#util#argsescape(opts))
endif
let makeprg = self.getExec() . ' build ' . opts . ' ' . syntastic#c#NullOutput()
let cleanup = 0
else
let opts = syntastic#util#var('go_go_test_args')
let opts = opts != '' ? syntastic#util#shescape(opts) : ''
if type(opts) != type('') || opts != ''
let opts = join(syntastic#util#argsescape(opts))
endif
let makeprg = self.getExec() . ' test -c ' . opts . ' ' . syntastic#c#NullOutput()
let cleanup = 1
endif