Merge branch 'master' into gcc_refactor
This commit is contained in:
commit
9b3eab1cb9
@ -53,6 +53,18 @@ function! syntastic#postprocess#cygwinRemoveCR(errors)
|
||||
return llist
|
||||
endfunction
|
||||
|
||||
" decode XML entities
|
||||
function! syntastic#postprocess#decodeXMLEntities(errors)
|
||||
let llist = []
|
||||
|
||||
for e in a:errors
|
||||
let e['text'] = syntastic#util#decodeXMLEntities(e['text'])
|
||||
call add(llist, e)
|
||||
endfor
|
||||
|
||||
return llist
|
||||
endfunction
|
||||
|
||||
" filter out errors referencing other files
|
||||
function! syntastic#postprocess#filterForeignErrors(errors)
|
||||
return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr(''))
|
||||
|
@ -161,12 +161,23 @@ endfunction
|
||||
|
||||
" A less noisy shellescape()
|
||||
function! syntastic#util#shescape(string)
|
||||
return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string, 1)
|
||||
return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string)
|
||||
endfunction
|
||||
|
||||
" A less noisy shellescape(expand())
|
||||
function! syntastic#util#shexpand(string)
|
||||
return syntastic#util#shescape(escape(expand(a:string), '|'))
|
||||
return syntastic#util#shescape(expand(a:string))
|
||||
endfunction
|
||||
|
||||
" decode XML entities
|
||||
function! syntastic#util#decodeXMLEntities(string)
|
||||
let str = a:string
|
||||
let str = substitute(str, '<', '<', 'g')
|
||||
let str = substitute(str, '>', '>', 'g')
|
||||
let str = substitute(str, '"', '"', 'g')
|
||||
let str = substitute(str, ''', "'", 'g')
|
||||
let str = substitute(str, '&', '\&', 'g')
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#debug(msg)
|
||||
|
@ -240,9 +240,9 @@ function! s:ShowLocList()
|
||||
call loclist.show()
|
||||
endfunction
|
||||
|
||||
"the script changes &shellpipe and &shell to stop the screen flicking when
|
||||
"the script changes &shellredir and &shell to stop the screen flicking when
|
||||
"shelling out to syntax checkers. Not all OSs support the hacks though
|
||||
function! s:OSSupportsShellpipeHack()
|
||||
function! s:OSSupportsShellredirHack()
|
||||
return !s:running_windows && executable('/bin/bash') && (s:uname() !~ "FreeBSD") && (s:uname() !~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
@ -336,9 +336,8 @@ function! SyntasticStatuslineFlag()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"A wrapper for the :lmake command. Sets up the make environment according to
|
||||
"the options given, runs make, resets the environment, returns the location
|
||||
"list
|
||||
"Emulates the :lmake command. Sets up the make environment according to the
|
||||
"options given, runs make, resets the environment, returns the location list
|
||||
"
|
||||
"a:options can contain the following keys:
|
||||
" 'makeprg'
|
||||
@ -350,6 +349,7 @@ endfunction
|
||||
"a:options may also contain:
|
||||
" 'defaults' - a dict containing default values for the returned errors
|
||||
" 'subtype' - all errors will be assigned the given subtype
|
||||
" 'preprocess' - a function to be applied to the error file before parsing errors
|
||||
" 'postprocess' - a list of functions to be applied to the error list
|
||||
" 'cwd' - change directory to the given path before running the checker
|
||||
" 'returns' - a list of valid exit codes for the checker
|
||||
@ -357,27 +357,22 @@ function! SyntasticMake(options)
|
||||
call syntastic#util#debug('SyntasticMake: called with options: '. string(a:options))
|
||||
|
||||
let old_loclist = getloclist(0)
|
||||
let old_makeprg = &l:makeprg
|
||||
let old_shellpipe = &shellpipe
|
||||
let old_shell = &shell
|
||||
let old_errorformat = &l:errorformat
|
||||
let old_shellredir = &shellredir
|
||||
let old_errorformat = &errorformat
|
||||
let old_cwd = getcwd()
|
||||
let old_lc_messages = $LC_MESSAGES
|
||||
let old_lc_all = $LC_ALL
|
||||
|
||||
if s:OSSupportsShellpipeHack()
|
||||
if s:OSSupportsShellredirHack()
|
||||
"this is a hack to stop the screen needing to be ':redraw'n when
|
||||
"when :lmake is run. Otherwise the screen flickers annoyingly
|
||||
let &shellpipe='&>'
|
||||
let &shellredir = '&>'
|
||||
let &shell = '/bin/bash'
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'makeprg')
|
||||
let &l:makeprg = a:options['makeprg']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &l:errorformat = a:options['errorformat']
|
||||
let &errorformat = a:options['errorformat']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'cwd')
|
||||
@ -386,10 +381,15 @@ function! SyntasticMake(options)
|
||||
|
||||
let $LC_MESSAGES = 'C'
|
||||
let $LC_ALL = ''
|
||||
silent lmake!
|
||||
let err_lines = system(a:options['makeprg'])
|
||||
let $LC_ALL = old_lc_all
|
||||
let $LC_MESSAGES = old_lc_messages
|
||||
|
||||
if has_key(a:options, 'preprocess')
|
||||
let err_lines = call(a:options['preprocess'], [err_lines])
|
||||
endif
|
||||
lgetexpr err_lines
|
||||
|
||||
let errors = getloclist(0)
|
||||
|
||||
if has_key(a:options, 'cwd')
|
||||
@ -397,9 +397,8 @@ function! SyntasticMake(options)
|
||||
endif
|
||||
|
||||
call setloclist(0, old_loclist)
|
||||
let &l:makeprg = old_makeprg
|
||||
let &l:errorformat = old_errorformat
|
||||
let &shellpipe=old_shellpipe
|
||||
let &errorformat = old_errorformat
|
||||
let &shellredir = old_shellredir
|
||||
let &shell=old_shell
|
||||
|
||||
if s:IsRedrawRequiredAfterMake()
|
||||
|
@ -45,7 +45,7 @@ function! SyntaxCheckers_eruby_ruby_GetLocList()
|
||||
\ syntastic#util#shescape('puts ERB.new(File.read(' .
|
||||
\ fname . encoding_spec .
|
||||
\ ').gsub(''<%='',''<%''), nil, ''-'').src') .
|
||||
\ ' \| ' . exe . ' -c'
|
||||
\ ' | ' . exe . ' -c'
|
||||
|
||||
let errorformat =
|
||||
\ '%-GSyntax OK,'.
|
||||
|
@ -51,12 +51,26 @@ function! SyntaxCheckers_html_validator_IsAvailable()
|
||||
return executable('curl') && executable('awk')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_validator_Preprocess(errors)
|
||||
let out = copy(a:errors)
|
||||
for n in range(len(out))
|
||||
let parts = matchlist(out[n], '\v^"([^"]+)"(.+)')
|
||||
" URL decode, except leave alone any "+"
|
||||
let parts[1] = substitute(parts[1], '\m%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
|
||||
let parts[1] = substitute(parts[1], '\\"', '"', 'g')
|
||||
let parts[1] = substitute(parts[1], '\\\\', '\\', 'g')
|
||||
let out[n] = '"' . parts[1] . '"' . parts[2]
|
||||
endfor
|
||||
return out
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_validator_GetLocList()
|
||||
let makeprg = 'curl -s --compressed -F out=gnu -F asciiquotes=yes' .
|
||||
\ (!empty(g:syntastic_html_validator_parser) ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
|
||||
\ (!empty(g:syntastic_html_validator_nsfilter) ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .
|
||||
\ ' -F doc=@' . syntastic#util#shexpand('%') . '\;type=text/html\;filename=' . syntastic#util#shexpand('%') . ' ' .
|
||||
\ g:syntastic_html_validator_api . ' \| ' . s:decoder
|
||||
\ g:syntastic_html_validator_api
|
||||
|
||||
let errorformat =
|
||||
\ '%E"%f":%l: %trror: %m,' .
|
||||
\ '%E"%f":%l-%\d%\+: %trror: %m,' .
|
||||
@ -70,7 +84,12 @@ function! SyntaxCheckers_html_validator_GetLocList()
|
||||
\ '%W"%f":%l-%\d%\+: info %tarning: %m,' .
|
||||
\ '%W"%f":%l%\%.%c: info %tarning: %m,' .
|
||||
\ '%W"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: info %tarning: %m'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_html_validator_Preprocess',
|
||||
\ 'returns': [0] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/awk -f
|
||||
#============================================================================
|
||||
#File: validator_decode.awk
|
||||
#Description: Helper script for validator.vim
|
||||
#Maintainer: LCD 47 <lcd047 at gmail dot com>
|
||||
#License: This program is free software. It comes without any warranty,
|
||||
# to the extent permitted by applicable law. You can redistribute
|
||||
# it and/or modify it under the terms of the Do What The Fuck You
|
||||
# Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
# See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
#
|
||||
#============================================================================
|
||||
|
||||
BEGIN {
|
||||
FS = OFS = "\""
|
||||
hextab ["0"] = 0; hextab ["8"] = 8;
|
||||
hextab ["1"] = 1; hextab ["9"] = 9;
|
||||
hextab ["2"] = 2; hextab ["A"] = hextab ["a"] = 10
|
||||
hextab ["3"] = 3; hextab ["B"] = hextab ["b"] = 11;
|
||||
hextab ["4"] = 4; hextab ["C"] = hextab ["c"] = 12;
|
||||
hextab ["5"] = 5; hextab ["D"] = hextab ["d"] = 13;
|
||||
hextab ["6"] = 6; hextab ["E"] = hextab ["e"] = 14;
|
||||
hextab ["7"] = 7; hextab ["F"] = hextab ["f"] = 15;
|
||||
}
|
||||
|
||||
function urldecode (url) {
|
||||
decoded = ""
|
||||
i = 1
|
||||
len = length (url)
|
||||
while ( i <= len ) {
|
||||
c = substr (url, i, 1)
|
||||
if ( c == "%" ) {
|
||||
if ( i + 2 <= len ) {
|
||||
c1 = substr (url, i + 1, 1)
|
||||
c2 = substr (url, i + 2, 1)
|
||||
if ( hextab [c1] != "" && hextab [c2] != "" ) {
|
||||
code = 0 + hextab [c1] * 16 + hextab [c2] + 0
|
||||
c = sprintf ("%c", code)
|
||||
}
|
||||
else
|
||||
c = c c1 c2
|
||||
i += 2
|
||||
}
|
||||
else if ( i + 1 <= len ) {
|
||||
c = substr (url, i, 2)
|
||||
i++
|
||||
}
|
||||
}
|
||||
else if ( c == "+" )
|
||||
c = " "
|
||||
decoded = decoded c
|
||||
i++
|
||||
}
|
||||
return decoded
|
||||
}
|
||||
|
||||
{
|
||||
$2 = urldecode($2)
|
||||
gsub ("\\\\\"", "\"", $2)
|
||||
print
|
||||
}
|
@ -27,9 +27,21 @@ function! SyntaxCheckers_java_checkstyle_IsAvailable()
|
||||
return executable('java')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_java_checkstyle_Preprocess(errors)
|
||||
let out = copy(a:errors)
|
||||
for n in range(len(out))
|
||||
let parts = matchlist(out[n], '\(.*<file name="\)\([^"]\+\)\(">.*\)')
|
||||
if len(parts) >= 4
|
||||
let parts[2] = syntastic#util#decodeXMLEntities(parts[2])
|
||||
let out[n] = join(parts[1:3], '')
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_java_checkstyle_GetLocList()
|
||||
|
||||
let fname = fnameescape( expand('%:p:h') . '/' . expand('%:t') )
|
||||
let fname = syntastic#util#shescape( expand('%:p:h') . '/' . expand('%:t') )
|
||||
|
||||
if has('win32unix')
|
||||
let fname = substitute(system('cygpath -m ' . fname), '\%x00', '', 'g')
|
||||
@ -38,20 +50,27 @@ function! SyntaxCheckers_java_checkstyle_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'java',
|
||||
\ 'args': '-cp ' . g:syntastic_java_checkstyle_classpath .
|
||||
\ ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file,
|
||||
\ ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file .
|
||||
\ ' -f xml',
|
||||
\ 'fname': fname,
|
||||
\ 'filetype': 'java',
|
||||
\ 'subchecker': 'checkstyle' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c:\ %m,' .
|
||||
\ '%f:%l:\ %m'
|
||||
\ '%P<file name="%f">,' .
|
||||
\ '%Q</file>,' .
|
||||
\ '%E<error line="%l" column="%c" severity="%trror" message="%m" source="%.%#"/>,' .
|
||||
\ '%E<error line="%l" severity="%trror" message="%m" source="%.%#"/>,' .
|
||||
\ '%E<error line="%l" column="%c" severity="%tarning" message="%m" source="%.%#"/>,' .
|
||||
\ '%E<error line="%l" severity="%tarning" message="%m" source="%.%#"/>,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'postprocess': ['cygwinRemoveCR'] })
|
||||
\ 'preprocess': 'SyntaxCheckers_java_checkstyle_Preprocess',
|
||||
\ 'postprocess': ['cygwinRemoveCR', 'decodeXMLEntities'] })
|
||||
|
||||
endfunction
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user