This commit is contained in:
LCD 47 2013-05-13 16:37:16 +03:00
parent cd289e45f0
commit 68cfe6513b
4 changed files with 93 additions and 91 deletions

View File

@ -36,6 +36,22 @@ function syntastic#postprocess#compressWhitespace(errors)
return llist
endfunction
" remove spurious CR under Cygwin
function! syntastic#postprocess#cygwinRemoveCR(errors)
if has('win32unix')
let llist = []
for e in a:errors
let e['text'] = substitute(e['text'], '\r', '', 'g')
call add(llist, e)
endfor
else
let llist = a:errors
endif
return llist
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:

View File

@ -27,47 +27,28 @@ function! SyntaxCheckers_java_checkstyle_IsAvailable()
return executable('java')
endfunction
function! s:CygwinPath(path)
return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g')
endfunction
function! s:RemoveCarriageReturn(line)
return substitute(a:line, '\r', '', 'g')
endfunction
function! s:RemoveCarriageReturns(errors)
for error in a:errors
let error['text'] = s:RemoveCarriageReturn(error['text'])
endfor
endfunction
function! SyntaxCheckers_java_checkstyle_GetLocList()
let fname = fnameescape( expand('%:p:h') . '/' . expand('%:t') )
if has('win32unix')
let fname = s:CygwinPath(fname)
let fname = substitute(system('cygpath -m ' . fname), '\%x00', '', 'g')
endif
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,
\ 'args': '-cp ' . g:syntastic_java_checkstyle_classpath .
\ ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file,
\ 'fname': fname,
\ 'tail': '2>&1',
\ 'subchecker': 'checkstyle' })
" check style format
let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m'
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
if has('win32unix')
call s:RemoveCarriageReturns(errors)
endif
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'postprocess': ['cygwinRemoveCR'] })
return errors
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'java',
\ 'name': 'checkstyle'})

View File

@ -80,12 +80,6 @@ function! s:RemoveCarriageReturn(line)
return substitute(a:line, '\r', '', 'g')
endfunction
function! s:RemoveCarriageReturns(errors)
for error in a:errors
let error['text'] = s:RemoveCarriageReturn(error['text'])
endfor
endfunction
" recursively remove directory and all it's sub-directories
function! s:RemoveDir(dir)
if isdirectory(a:dir)
@ -150,9 +144,15 @@ function! s:EditClasspath()
if winnr < 0
let pathlist = split(g:syntastic_java_javac_classpath,"\n")
execute (len(pathlist) + 5) . 'sp ' . fnameescape(command)
au BufWriteCmd <buffer> call s:SaveClasspath() | bwipeout
augroup syntastic
autocmd BufWriteCmd <buffer> call s:SaveClasspath() | bwipeout
augroup END
setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile nowrap number
for p in pathlist | call append(line('$')-1,p) | endfor
for p in pathlist
call append(line('$') - 1, p)
endfor
else
execute winnr . 'wincmd w'
endif
@ -164,6 +164,7 @@ function! s:GetMavenClasspath()
if g:syntastic_java_javac_maven_pom_ftime != getftime('pom.xml') || g:syntastic_java_javac_maven_pom_cwd != getcwd()
let mvn_classpath_output = split(system(g:syntastic_java_maven_executable . ' dependency:build-classpath'), "\n")
let class_path_next = 0
for line in mvn_classpath_output
if class_path_next == 1
let mvn_classpath = s:RemoveCarriageReturn(line)
@ -173,8 +174,10 @@ function! s:GetMavenClasspath()
let class_path_next = 1
endif
endfor
let mvn_classpath = s:AddToClasspath(mvn_classpath, 'target/classes')
let mvn_classpath = s:AddToClasspath(mvn_classpath, 'target/test-classes')
let g:syntastic_java_javac_maven_pom_cwd = getcwd()
let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml')
let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath
@ -234,7 +237,9 @@ function! SyntaxCheckers_java_javac_GetLocList()
endtry
if type(ps) == type([])
for p in ps
if p != '' | let javac_classpath = s:AddToClasspath(javac_classpath,p) | endif
if p != ''
let javac_classpath = s:AddToClasspath(javac_classpath,p)
endif
endfor
else
let javac_classpath = s:AddToClasspath(javac_classpath,ps)
@ -281,11 +286,7 @@ function! SyntaxCheckers_java_javac_GetLocList()
if g:syntastic_java_javac_delete_output
silent! call mkdir(output_dir,'p')
endif
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
if has('win32unix')
call s:RemoveCarriageReturns(errors)
endif
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'postprocess': ['cygwinRemoveCR'] })
if g:syntastic_java_javac_delete_output
call s:RemoveDir(output_dir)

View File

@ -42,11 +42,15 @@ function! SyntaxCheckers_sass_sass_GetLocList()
\ 'exe': 'sass',
\ 'args': '--cache-location ' . s:sass_cache_location . ' ' . s:imports . ' --check',
\ 'subchecker': 'sass' })
let errorformat = '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#'
let errorformat .= ',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m'
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
let errorformat =
\ '%ESyntax %trror:%m,' .
\ '%C on line %l of %f,' .
\ '%Z%.%#,' .
\ '%Wwarning on line %l:,' .
\ '%Z%m,' .
\ 'Syntax %trror on line %l: %m'
return loclist
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({