YcmDiags now doesn't hang when no flags available

Fixes #46
This commit is contained in:
Strahinja Val Markovic 2013-02-05 21:22:50 -08:00
parent 9bee28a0a8
commit 6f10d7aad7
4 changed files with 28 additions and 1 deletions

View File

@ -438,13 +438,27 @@ function! s:ForceCompile()
if diagnostics_ready if diagnostics_ready
break break
endif endif
let getting_completions = pyeval(
\ 'ycm_state.GettingCompletions()' )
if !getting_completions
echom "Unable to retrieve diagnostics."
return 0
endif
sleep 100m sleep 100m
endwhile endwhile
return 1
endfunction endfunction
function! s:ForceCompileAndDiagnostics() function! s:ForceCompileAndDiagnostics()
call s:ForceCompile() let compilation_succeeded = s:ForceCompile()
if !compilation_succeeded
return
endif
call s:UpdateDiagnosticNotifications() call s:UpdateDiagnosticNotifications()
echom "Diagnostics refreshed." echom "Diagnostics refreshed."
endfunction endfunction

View File

@ -81,6 +81,9 @@ class Completer( object ):
def ShowDetailedDiagnostic( self ): def ShowDetailedDiagnostic( self ):
pass pass
def GettingCompletions( self ):
return False
@abc.abstractmethod @abc.abstractmethod
def SupportedFiletypes( self ): def SupportedFiletypes( self ):

View File

@ -146,6 +146,10 @@ class ClangCompleter( Completer ):
return self.parse_future.ResultsReady() return self.parse_future.ResultsReady()
def GettingCompletions( self ):
return self.completer.UpdatingTranslationUnit( vim.current.buffer.name )
def GetDiagnosticsForCurrentFile( self ): def GetDiagnosticsForCurrentFile( self ):
if self.DiagnosticsForCurrentFileReady(): if self.DiagnosticsForCurrentFileReady():
diagnostics = self.completer.DiagnosticsForFile( vim.current.buffer.name ) diagnostics = self.completer.DiagnosticsForFile( vim.current.buffer.name )

View File

@ -141,6 +141,12 @@ class YouCompleteMe( object ):
return self.GetFiletypeCompleterForCurrentFile().ShowDetailedDiagnostic() return self.GetFiletypeCompleterForCurrentFile().ShowDetailedDiagnostic()
def GettingCompletions( self ):
if self.FiletypeCompletionEnabledForCurrentFile():
return self.GetFiletypeCompleterForCurrentFile().GettingCompletions()
return False
def OnCurrentIdentifierFinished( self ): def OnCurrentIdentifierFinished( self ):
self.identcomp.OnCurrentIdentifierFinished() self.identcomp.OnCurrentIdentifierFinished()