Merge branch 'master' into gcc_refactor

This commit is contained in:
LCD 47 2013-06-22 20:02:01 +03:00
commit a409c6dd86
5 changed files with 78 additions and 56 deletions

View File

@ -21,13 +21,15 @@ function! g:SyntasticBalloonsNotifier.New()
endfunction endfunction
function! g:SyntasticBalloonsNotifier.enabled() function! g:SyntasticBalloonsNotifier.enabled()
return exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons return
\ has('balloon_eval') &&
\ (exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons)
endfunction endfunction
" Update the error balloons " Update the error balloons
function! g:SyntasticBalloonsNotifier.refresh(loclist) function! g:SyntasticBalloonsNotifier.refresh(loclist)
let b:syntastic_balloons = {} let b:syntastic_balloons = {}
if a:loclist.hasErrorsOrWarningsToDisplay() if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
let buf = bufnr('') let buf = bufnr('')
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf') let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
if !empty(issues) if !empty(issues)
@ -45,7 +47,9 @@ endfunction
" Reset the error balloons " Reset the error balloons
function! g:SyntasticBalloonsNotifier.reset(loclist) function! g:SyntasticBalloonsNotifier.reset(loclist)
if has('balloon_eval')
set nobeval set nobeval
endif
endfunction endfunction
" Private functions {{{1 " Private functions {{{1

View File

@ -16,9 +16,12 @@ function! g:SyntasticCursorNotifier.New()
return newObj return newObj
endfunction endfunction
function! g:SyntasticCursorNotifier.enabled()
return exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
endfunction
function! g:SyntasticCursorNotifier.refresh(loclist) function! g:SyntasticCursorNotifier.refresh(loclist)
let enabled = exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
if enabled && a:loclist.hasErrorsOrWarningsToDisplay()
let b:syntastic_messages = copy(a:loclist.messages(bufnr(''))) let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
let b:oldLine = -1 let b:oldLine = -1
autocmd! syntastic CursorMoved autocmd! syntastic CursorMoved

View File

@ -3,15 +3,13 @@ if exists("g:loaded_syntastic_notifier_highlighting")
endif endif
let g:loaded_syntastic_notifier_highlighting = 1 let g:loaded_syntastic_notifier_highlighting = 1
" Highlighting requires getmatches introduced in 7.1.040
let s:has_highlighting = v:version > 701 || (v:version == 701 && has('patch040'))
if !exists("g:syntastic_enable_highlighting") if !exists("g:syntastic_enable_highlighting")
let g:syntastic_enable_highlighting = 1 let g:syntastic_enable_highlighting = 1
endif endif
" Highlighting requires getmatches introduced in 7.1.040
if v:version < 701 || (v:version == 701 && !has('patch040'))
let g:syntastic_enable_highlighting = 0
endif
let g:SyntasticHighlightingNotifier = {} let g:SyntasticHighlightingNotifier = {}
" Public methods {{{1 " Public methods {{{1
@ -22,11 +20,14 @@ function! g:SyntasticHighlightingNotifier.New()
endfunction endfunction
function! g:SyntasticHighlightingNotifier.enabled() function! g:SyntasticHighlightingNotifier.enabled()
return exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting return
\ s:has_highlighting &&
\ (exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting)
endfunction endfunction
" Sets error highlights in the cuirrent window " Sets error highlights in the cuirrent window
function! g:SyntasticHighlightingNotifier.refresh(loclist) function! g:SyntasticHighlightingNotifier.refresh(loclist)
if self.enabled()
call self.reset(a:loclist) call self.reset(a:loclist)
let buf = bufnr('') let buf = bufnr('')
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf') let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
@ -48,15 +49,18 @@ function! g:SyntasticHighlightingNotifier.refresh(loclist)
call matchadd(group, '\%' . item['lnum'] . 'l\%' . lcol . coltype) call matchadd(group, '\%' . item['lnum'] . 'l\%' . lcol . coltype)
endif endif
endfor endfor
endif
endfunction endfunction
" Remove all error highlights from the window " Remove all error highlights from the window
function! g:SyntasticHighlightingNotifier.reset(loclist) function! g:SyntasticHighlightingNotifier.reset(loclist)
if s:has_highlighting
for match in getmatches() for match in getmatches()
if stridx(match['group'], 'Syntastic') == 0 if stridx(match['group'], 'Syntastic') == 0
call matchdelete(match['id']) call matchdelete(match['id'])
endif endif
endfor endfor
endif
endfunction endfunction
" vim: set sw=4 sts=4 et fdm=marker: " vim: set sw=4 sts=4 et fdm=marker:

View File

@ -30,7 +30,11 @@ endfunction
function! g:SyntasticNotifiers.reset(loclist) function! g:SyntasticNotifiers.reset(loclist)
for type in self._enabled_types for type in self._enabled_types
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '') let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
if has_key(g:{class}, 'reset') && (!has_key(g:{class}, 'enabled') || self._notifier[type].enabled())
" reset notifiers regardless if they are enabled or not, since
" the user might have disabled them since the last refresh();
" notifiers MUST be prepared to deal with reset() when disabled
if has_key(g:{class}, 'reset')
call self._notifier[type].reset(a:loclist) call self._notifier[type].reset(a:loclist)
endif endif
endfor endfor

View File

@ -23,10 +23,6 @@ if !exists("g:syntastic_style_warning_symbol")
let g:syntastic_style_warning_symbol = 'S>' let g:syntastic_style_warning_symbol = 'S>'
endif endif
if !has('signs')
let g:syntastic_enable_signs = 0
endif
" start counting sign ids at 5000, start here to hopefully avoid conflicting " start counting sign ids at 5000, start here to hopefully avoid conflicting
" with any other code that places signs (not sure if this precaution is " with any other code that places signs (not sure if this precaution is
@ -52,13 +48,16 @@ function! g:SyntasticSignsNotifier.New()
endfunction endfunction
function! g:SyntasticSignsNotifier.enabled() function! g:SyntasticSignsNotifier.enabled()
return exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs return
\ has('signs') &&
\ exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
endfunction endfunction
" Update the error signs
function! g:SyntasticSignsNotifier.refresh(loclist) function! g:SyntasticSignsNotifier.refresh(loclist)
let old_signs = copy(self._bufSignIds()) let old_signs = copy(self._bufSignIds())
if self.enabled()
call self._signErrors(a:loclist) call self._signErrors(a:loclist)
endif
call self._removeSigns(old_signs) call self._removeSigns(old_signs)
let s:first_sign_id = s:next_sign_id let s:first_sign_id = s:next_sign_id
endfunction endfunction
@ -104,14 +103,19 @@ function! g:SyntasticSignsNotifier._signErrors(loclist)
let loclist = a:loclist let loclist = a:loclist
if loclist.hasErrorsOrWarningsToDisplay() if loclist.hasErrorsOrWarningsToDisplay()
" make sure the errors come after the warnings, so that errors mask " errors some first, so that they are not masked by warnings
" the warnings on the same line, not the other way around
let buf = bufnr('') let buf = bufnr('')
let issues = loclist.quietWarnings() ? [] : loclist.warnings() let issues = copy(loclist.errors())
call extend(issues, loclist.errors()) if !loclist.quietWarnings()
call extend(issues, loclist.warnings())
endif
call filter(issues, 'v:val["bufnr"] == buf') call filter(issues, 'v:val["bufnr"] == buf')
let seen = {}
for i in issues for i in issues
if !has_key(seen, i['lnum'])
let seen[i['lnum']] = 1
let sign_severity = i['type'] ==? 'W' ? 'Warning' : 'Error' let sign_severity = i['type'] ==? 'W' ? 'Warning' : 'Error'
let sign_subtype = get(i, 'subtype', '') let sign_subtype = get(i, 'subtype', '')
let sign_type = 'Syntastic' . sign_subtype . sign_severity let sign_type = 'Syntastic' . sign_subtype . sign_severity
@ -119,16 +123,19 @@ function! g:SyntasticSignsNotifier._signErrors(loclist)
exec "sign place " . s:next_sign_id . " line=" . i['lnum'] . " name=" . sign_type . " buffer=" . i['bufnr'] exec "sign place " . s:next_sign_id . " line=" . i['lnum'] . " name=" . sign_type . " buffer=" . i['bufnr']
call add(self._bufSignIds(), s:next_sign_id) call add(self._bufSignIds(), s:next_sign_id)
let s:next_sign_id += 1 let s:next_sign_id += 1
endif
endfor endfor
endif endif
endfunction endfunction
" Remove the signs with the given ids from this buffer " Remove the signs with the given ids from this buffer
function! g:SyntasticSignsNotifier._removeSigns(ids) function! g:SyntasticSignsNotifier._removeSigns(ids)
if has('signs')
for i in a:ids for i in a:ids
exec "sign unplace " . i exec "sign unplace " . i
call remove(self._bufSignIds(), index(self._bufSignIds(), i)) call remove(self._bufSignIds(), index(self._bufSignIds(), i))
endfor endfor
endif
endfunction endfunction
" Get all the ids of the SyntaxError signs in the buffer " Get all the ids of the SyntaxError signs in the buffer