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