Moved syntastic#gcc#GetLocList() to autoload/syntastic/c.vim.

This commit is contained in:
LCD 47 2013-05-30 19:44:12 +03:00
parent 4a6ece567a
commit a8be73d113
9 changed files with 71 additions and 83 deletions

View File

@ -122,6 +122,70 @@ function! syntastic#c#SearchHeaders()
return includes return includes
endfunction endfunction
" GetLocList() for C-like compilers
function! syntastic#c#GetLocList(filetype, options)
let ft = a:filetype
let errorformat = exists('g:syntastic_' . ft . '_errorformat') ?
\ g:syntastic_{ft}_errorformat : a:options['errorformat']
" determine whether to parse header files as well
if expand('%') =~? a:options['headers_pattern']
if exists('g:syntastic_' . ft . '_check_header') && g:syntastic_{ft}_check_header
let makeprg =
\ g:syntastic_{ft}_compiler .
\ ' ' . get(a:options, 'makeprg_headers', '') .
\ ' ' . g:syntastic_{ft}_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
\ ' ' . syntastic#c#NullOutput(ft) .
\ ' -c ' . shellescape(expand('%'))
else
return []
endif
else
let makeprg =
\ g:syntastic_{ft}_compiler .
\ ' ' . get(a:options, 'makeprg_main', '') .
\ ' ' . g:syntastic_{ft}_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
\ ' ' . shellescape(expand('%'))
endif
" check if the user manually set some cflags
if !exists('b:syntastic_' . ft . '_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_' . ft . '_no_include_search') || !g:syntastic_{ft}_no_include_search
if ft ==# 'c' || ft ==# 'cpp'
" refresh the include file search if desired
if exists('g:syntastic_' . ft . '_auto_refresh_includes') && g:syntastic_{ft}_auto_refresh_includes
let makeprg .= ' ' . syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_' . ft . '_includes')
let b:syntastic_{ft}_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= ' ' . b:syntastic_{ft}_includes
endif
endif
endif
else
" use the user-defined cflags
let makeprg .= ' ' . b:syntastic_{ft}_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors
call filter(errors, 'get(v:val, "bufnr") == ' . bufnr(''))
endif
return errors
endfunction
" Private functions {{{1 " Private functions {{{1
" initialize c/cpp syntax checker handlers " initialize c/cpp syntax checker handlers

View File

@ -1,76 +0,0 @@
if exists("g:loaded_syntastic_gcc_autoload")
finish
endif
let g:loaded_syntastic_gcc_autoload = 1
let s:save_cpo = &cpo
set cpo&vim
function! syntastic#gcc#GetLocList(filetype, options)
let ft = a:filetype
let errorformat = exists('g:syntastic_' . ft . '_errorformat') ?
\ g:syntastic_{ft}_errorformat : a:options['errorformat']
" determine whether to parse header files as well
if expand('%') =~? a:options['headers_pattern']
if exists('g:syntastic_' . ft . '_check_header') && g:syntastic_{ft}_check_header
let makeprg =
\ g:syntastic_{ft}_compiler .
\ ' ' . get(a:options, 'makeprg_headers', '') .
\ ' ' . g:syntastic_{ft}_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
\ ' ' . syntastic#c#NullOutput(ft) .
\ ' -c ' . shellescape(expand('%'))
else
return []
endif
else
let makeprg =
\ g:syntastic_{ft}_compiler .
\ ' ' . get(a:options, 'makeprg_main', '') .
\ ' ' . g:syntastic_{ft}_compiler_options .
\ ' ' . syntastic#c#GetIncludeDirs(ft) .
\ ' ' . shellescape(expand('%'))
endif
" check if the user manually set some cflags
if !exists('b:syntastic_' . ft . '_cflags')
" check whether to search for include files at all
if !exists('g:syntastic_' . ft . '_no_include_search') || !g:syntastic_{ft}_no_include_search
if ft ==# 'c' || ft ==# 'cpp'
" refresh the include file search if desired
if exists('g:syntastic_' . ft . '_auto_refresh_includes') && g:syntastic_{ft}_auto_refresh_includes
let makeprg .= ' ' . syntastic#c#SearchHeaders()
else
" search for header includes if not cached already
if !exists('b:syntastic_' . ft . '_includes')
let b:syntastic_{ft}_includes = syntastic#c#SearchHeaders()
endif
let makeprg .= ' ' . b:syntastic_{ft}_includes
endif
endif
endif
else
" use the user-defined cflags
let makeprg .= ' ' . b:syntastic_{ft}_cflags
endif
" add optional config file parameters
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_{ft}_config_file)
" process makeprg
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
" filter the processed errors if desired
if exists('g:syntastic_' . ft . '_remove_include_errors') && g:syntastic_{ft}_remove_include_errors
call filter(errors, 'get(v:val, "bufnr") == ' . bufnr(''))
endif
return errors
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4 fdm=marker:

View File

@ -32,7 +32,7 @@ if !exists('g:syntastic_ada_config_file')
endif endif
function! SyntaxCheckers_ada_gcc_GetLocList() function! SyntaxCheckers_ada_gcc_GetLocList()
return syntastic#gcc#GetLocList('ada', { return syntastic#c#GetLocList('ada', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .
\ '%f:%l:%c: %m,' . \ '%f:%l:%c: %m,' .

View File

@ -36,7 +36,7 @@ if !exists('g:syntastic_c_config_file')
endif endif
function! SyntaxCheckers_c_gcc_GetLocList() function! SyntaxCheckers_c_gcc_GetLocList()
return syntastic#gcc#GetLocList('c', { return syntastic#c#GetLocList('c', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .

View File

@ -35,7 +35,7 @@ if !exists('g:syntastic_cpp_config_file')
endif endif
function! SyntaxCheckers_cpp_gcc_GetLocList() function! SyntaxCheckers_cpp_gcc_GetLocList()
return syntastic#gcc#GetLocList('cpp', { return syntastic#c#GetLocList('cpp', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .
\ '%f:%l:%c: %trror: %m,' . \ '%f:%l:%c: %trror: %m,' .

View File

@ -40,7 +40,7 @@ if !exists('g:syntastic_d_config_file')
endif endif
function! SyntaxCheckers_d_dmd_GetLocList() function! SyntaxCheckers_d_dmd_GetLocList()
return syntastic#gcc#GetLocList('d', { return syntastic#c#GetLocList('d', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,%f(%l): %m,' . \ '%-G%f:%s:,%f(%l): %m,' .
\ '%f:%l: %m', \ '%f:%l: %m',

View File

@ -35,7 +35,7 @@ if !exists('g:syntastic_objc_config_file')
endif endif
function! SyntaxCheckers_objc_gcc_GetLocList() function! SyntaxCheckers_objc_gcc_GetLocList()
return syntastic#gcc#GetLocList('objc', { return syntastic#c#GetLocList('objc', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .

View File

@ -35,7 +35,7 @@ if !exists('g:syntastic_objcpp_config_file')
endif endif
function! SyntaxCheckers_objcpp_gcc_GetLocList() function! SyntaxCheckers_objcpp_gcc_GetLocList()
return syntastic#gcc#GetLocList('objcpp', { return syntastic#c#GetLocList('objcpp', {
\ 'errorformat': \ 'errorformat':
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .
\ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .