Smarter updating of clang diagnostics display
This commit is contained in:
parent
71e3e86252
commit
11e42b49f0
@ -41,7 +41,7 @@ function! youcompleteme#Enable()
|
||||
augroup youcompleteme
|
||||
autocmd!
|
||||
autocmd CursorMovedI * call s:OnCursorMovedInsertMode()
|
||||
" autocmd CursorMoved * call s:OnCursorMovedNormalMode()
|
||||
autocmd CursorMoved * call s:OnCursorMovedNormalMode()
|
||||
" Note that these events will NOT trigger for the file vim is started with;
|
||||
" so if you do "vim foo.cc", these events will not trigger when that buffer
|
||||
" is read. This is because youcompleteme#Enable() is called on VimEnter and
|
||||
@ -134,9 +134,9 @@ function! s:OnCursorMovedInsertMode()
|
||||
endfunction
|
||||
|
||||
|
||||
" function! s:OnCursorMovedNormalMode()
|
||||
" call s:UpdateDiagnosticNotifications()
|
||||
" endfunction
|
||||
function! s:OnCursorMovedNormalMode()
|
||||
call s:UpdateDiagnosticNotifications()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:OnInsertLeave()
|
||||
@ -147,6 +147,7 @@ endfunction
|
||||
|
||||
function! s:UpdateDiagnosticNotifications()
|
||||
if get( g:, 'loaded_syntastic_plugin', 0 ) && s:ClangEnabledForCurrentFile()
|
||||
\ && pyeval( 'clangcomp.DiagnosticsForCurrentFileReady()' )
|
||||
SyntasticCheck
|
||||
endif
|
||||
endfunction
|
||||
|
@ -413,10 +413,11 @@ void ClangCompleter::UpdateTranslationUnitAsync(
|
||||
|
||||
// Only ever set the task when it's NULL; if it's not, that means that the
|
||||
// clang thread is working on it
|
||||
if ( !file_parse_task_ ) {
|
||||
file_parse_task_ = make_shared< packaged_task< void > >( functor );
|
||||
file_parse_task_condition_variable_.notify_all();
|
||||
}
|
||||
if ( file_parse_task_ )
|
||||
return;
|
||||
|
||||
file_parse_task_ = make_shared< packaged_task< void > >( functor );
|
||||
file_parse_task_condition_variable_.notify_all();
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,11 +58,11 @@ BOOST_PYTHON_MODULE(indexer)
|
||||
class_< std::vector< Diagnostic > >( "DiagnosticVec" )
|
||||
.def( vector_indexing_suite< std::vector< Diagnostic > >() );
|
||||
|
||||
class_< Future< AsyncResults > >( "Future" )
|
||||
class_< Future< AsyncResults > >( "FutureResults" )
|
||||
.def( "ResultsReady", &Future< AsyncResults >::ResultsReady )
|
||||
.def( "GetResults", &Future< AsyncResults >::GetResults );
|
||||
|
||||
class_< Future< AsyncCompletions > >( "Future" )
|
||||
class_< Future< AsyncCompletions > >( "FutureCompletions" )
|
||||
.def( "ResultsReady", &Future< AsyncCompletions >::ResultsReady )
|
||||
.def( "GetResults", &Future< AsyncCompletions >::GetResults );
|
||||
|
||||
|
@ -118,6 +118,8 @@ class ClangCompleter( Completer ):
|
||||
self.completer.EnableThreading()
|
||||
self.contents_holder = []
|
||||
self.filename_holder = []
|
||||
self.last_diagnostics = []
|
||||
self.possibly_new_diagnostics = False
|
||||
|
||||
|
||||
def GetUnsavedFilesVector( self ):
|
||||
@ -179,15 +181,23 @@ class ClangCompleter( Completer ):
|
||||
|
||||
|
||||
def OnFileReadyToParse( self ):
|
||||
self.possibly_new_diagnostics = True
|
||||
self.completer.UpdateTranslationUnitAsync( vim.current.buffer.name,
|
||||
self.GetUnsavedFilesVector() )
|
||||
|
||||
|
||||
def DiagnosticsForCurrentFileReady( self ):
|
||||
return ( self.possibly_new_diagnostics and not
|
||||
self.completer.UpdatingTranslationUnit() )
|
||||
|
||||
|
||||
def GetDiagnosticsForCurrentFile( self ):
|
||||
if self.completer.UpdatingTranslationUnit():
|
||||
return []
|
||||
return [ DiagnosticToDict( x ) for x in
|
||||
self.completer.DiagnosticsForFile( vim.current.buffer.name ) ]
|
||||
if self.DiagnosticsForCurrentFileReady():
|
||||
self.last_diagnostics = [ DiagnosticToDict( x ) for x in
|
||||
self.completer.DiagnosticsForFile(
|
||||
vim.current.buffer.name ) ]
|
||||
self.possibly_new_diagnostics = False
|
||||
return self.last_diagnostics
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user