Expose functions to get error and warning counts
This commit is contained in:
parent
e166907e98
commit
dafc36ba37
@ -870,6 +870,16 @@ function! s:ShowDiagnostics()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! g:YcmGetErrorCount()
|
||||||
|
return pyeval( 'ycm_state.GetErrorCount()' )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! g:YcmGetWarningCount()
|
||||||
|
return pyeval( 'ycm_state.GetWarningCount()' )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" This is basic vim plugin boilerplate
|
" This is basic vim plugin boilerplate
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
@ -43,6 +43,31 @@ class DiagnosticInterface( object ):
|
|||||||
if self._user_options[ 'echo_current_diagnostic' ]:
|
if self._user_options[ 'echo_current_diagnostic' ]:
|
||||||
self._EchoDiagnosticForLine( line )
|
self._EchoDiagnosticForLine( line )
|
||||||
|
|
||||||
|
|
||||||
|
def GetErrorCount( self ):
|
||||||
|
errors = 0
|
||||||
|
line_to_diags = self._buffer_number_to_line_to_diags[
|
||||||
|
vim.current.buffer.number ]
|
||||||
|
|
||||||
|
for diags in line_to_diags.itervalues():
|
||||||
|
for diag in diags:
|
||||||
|
if _DiagnosticIsError( diag ):
|
||||||
|
errors += 1
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def GetWarningCount( self ):
|
||||||
|
warnings = 0
|
||||||
|
line_to_diags = self._buffer_number_to_line_to_diags[
|
||||||
|
vim.current.buffer.number ]
|
||||||
|
|
||||||
|
for diags in line_to_diags.itervalues():
|
||||||
|
for diag in diags:
|
||||||
|
if _DiagnosticIsWarning( diag ):
|
||||||
|
warnings += 1
|
||||||
|
return warnings
|
||||||
|
|
||||||
|
|
||||||
def UpdateWithNewDiagnostics( self, diags ):
|
def UpdateWithNewDiagnostics( self, diags ):
|
||||||
normalized_diags = [ _NormalizeDiagnostic( x ) for x in diags ]
|
normalized_diags = [ _NormalizeDiagnostic( x ) for x in diags ]
|
||||||
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict(
|
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict(
|
||||||
@ -209,6 +234,10 @@ def _DiagnosticIsError( diag ):
|
|||||||
return diag[ 'kind' ] == 'ERROR'
|
return diag[ 'kind' ] == 'ERROR'
|
||||||
|
|
||||||
|
|
||||||
|
def _DiagnosticIsWarning( diag ):
|
||||||
|
return diag[ 'kind' ] == 'WARNING'
|
||||||
|
|
||||||
|
|
||||||
def _NormalizeDiagnostic( diag ):
|
def _NormalizeDiagnostic( diag ):
|
||||||
def ClampToOne( value ):
|
def ClampToOne( value ):
|
||||||
return value if value > 0 else 1
|
return value if value > 0 else 1
|
||||||
|
@ -451,6 +451,11 @@ class YouCompleteMe( object ):
|
|||||||
return None
|
return None
|
||||||
return completion[ "extra_data" ][ "required_namespace_import" ]
|
return completion[ "extra_data" ][ "required_namespace_import" ]
|
||||||
|
|
||||||
|
def GetErrorCount( self ):
|
||||||
|
return self._diag_interface.GetErrorCount()
|
||||||
|
|
||||||
|
def GetWarningCount( self ):
|
||||||
|
return self._diag_interface.GetWarningCount()
|
||||||
|
|
||||||
def DiagnosticsForCurrentFileReady( self ):
|
def DiagnosticsForCurrentFileReady( self ):
|
||||||
return bool( self._latest_file_parse_request and
|
return bool( self._latest_file_parse_request and
|
||||||
|
Loading…
Reference in New Issue
Block a user