Document YcmGetErrorCount and YcmGetWarningCount functions

This commit is contained in:
Kenny Kaye 2015-12-04 15:59:18 -08:00
parent dafc36ba37
commit 163238992c
3 changed files with 65 additions and 20 deletions

View File

@ -1122,6 +1122,30 @@ provides a list of implementations to choose from.
Supported in filetypes: `cs`
Functions
--------
### The `YcmGetErrorCount` function
Get the number of YCM Diagnostic errors. If no errors are present, this function
returns 0.
For example:
```viml
call YcmGetErrorCount()
```
### The `YcmGetWarningCount` function
Get the number of YCM Diagnostic warnings. If no warnings are present, this
function returns 0.
For example:
```viml
call YcmGetWarningCount()
```
Options
-------

View File

@ -55,7 +55,10 @@ Contents ~
14. The |ReloadSolution| subcommand
15. The |GoToImplementation| subcommand
16. The |GoToImplementationElseDeclaration| subcommand
8. Options |youcompleteme-options|
8. Functions |youcompleteme-functions|
1. The |YcmGetErrorCount| function
2. The |YcmGetWarningCount| function
9. Options |youcompleteme-options|
1. The |g:ycm_min_num_of_chars_for_completion| option
2. The |g:ycm_min_num_identifier_candidate_chars| option
3. The |g:ycm_auto_trigger| option
@ -101,7 +104,7 @@ Contents ~
43. The |g:ycm_use_ultisnips_completer| option
44. The |g:ycm_goto_buffer_command| option
45. The |g:ycm_disable_for_files_larger_than_kb| option
9. FAQ |youcompleteme-faq|
10. FAQ |youcompleteme-faq|
1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |import-vim|
2. On very rare occasions Vim crashes when I tab through the completion menu |youcompleteme-on-very-rare-occasions-vim-crashes-when-i-tab-through-completion-menu|
3. I get a linker warning regarding |libpython| on Mac when compiling YCM
@ -1346,6 +1349,30 @@ provides a list of implementations to choose from.
Supported in filetypes: 'cs'
===============================================================================
*youcompleteme-functions*
Functions ~
-------------------------------------------------------------------------------
The *YcmGetErrorCount* function
Get the number of YCM Diagnostic errors. If no errors are present, this function
returns 0.
For example:
>
call YcmGetErrorCount()
<
-------------------------------------------------------------------------------
The *YcmGetWarningCount* function
Get the number of YCM Diagnostic warnings. If no warnings are present, this
function returns 0.
For example:
>
call YcmGetWarningCount()
<
===============================================================================
*youcompleteme-options*
Options ~

View File

@ -45,27 +45,11 @@ class DiagnosticInterface( object ):
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
return len( self._FilterDiagnostics( _DiagnosticIsError ) )
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
return len( self._FilterDiagnostics( _DiagnosticIsWarning ) )
def UpdateWithNewDiagnostics( self, diags ):
@ -104,6 +88,16 @@ class DiagnosticInterface( object ):
self._diag_message_needs_clearing = True
def _FilterDiagnostics( self, predicate ):
matched_diags = []
line_to_diags = self._buffer_number_to_line_to_diags[
vim.current.buffer.number ]
for diags in line_to_diags.itervalues():
matched_diags.extend( filter( predicate, diags ) )
return matched_diags
def _UpdateSquiggles( buffer_number_to_line_to_diags ):
vimsupport.ClearYcmSyntaxMatches()
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]