|
@@ -25,7 +25,6 @@ from __future__ import absolute_import
|
|
|
from builtins import * # noqa
|
|
|
|
|
|
from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock,
|
|
|
- EmulateCurrentBufferChange,
|
|
|
MockVimBuffers, MockVimModule, VimBuffer )
|
|
|
MockVimModule()
|
|
|
|
|
@@ -106,7 +105,7 @@ def MockEventNotification( response_method, native_filetype_completer = True ):
|
|
|
'ycm.youcompleteme.YouCompleteMe.FiletypeCompleterExistsForFiletype',
|
|
|
return_value = native_filetype_completer ):
|
|
|
|
|
|
- with patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReady',
|
|
|
+ with patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReadyWithCache',
|
|
|
return_value = True ):
|
|
|
|
|
|
yield
|
|
@@ -142,7 +141,6 @@ def EventNotification_FileReadyToParse_NonDiagnostic_Error_test(
|
|
|
call( ERROR_TEXT, truncate = True )
|
|
|
] )
|
|
|
|
|
|
- EmulateCurrentBufferChange()
|
|
|
# But it does if a subsequent event raises again
|
|
|
ycm.OnFileReadyToParse()
|
|
|
ok_( ycm.FileParseRequestReady() )
|
|
@@ -212,7 +210,6 @@ def EventNotification_FileReadyToParse_NonDiagnostic_ConfirmExtraConf_test(
|
|
|
call( FILE_NAME ),
|
|
|
] )
|
|
|
|
|
|
- EmulateCurrentBufferChange()
|
|
|
# But it does if a subsequent event raises again
|
|
|
ycm.OnFileReadyToParse()
|
|
|
ok_( ycm.FileParseRequestReady() )
|
|
@@ -227,7 +224,6 @@ def EventNotification_FileReadyToParse_NonDiagnostic_ConfirmExtraConf_test(
|
|
|
call( FILE_NAME ),
|
|
|
] )
|
|
|
|
|
|
- EmulateCurrentBufferChange()
|
|
|
# When the user rejects the extra conf, we reject it
|
|
|
with patch( 'ycm.vimsupport.PresentDialog',
|
|
|
return_value = 1,
|
|
@@ -253,7 +249,6 @@ def EventNotification_FileReadyToParse_NonDiagnostic_ConfirmExtraConf_test(
|
|
|
call( FILE_NAME ),
|
|
|
] )
|
|
|
|
|
|
- EmulateCurrentBufferChange()
|
|
|
# But it does if a subsequent event raises again
|
|
|
ycm.OnFileReadyToParse()
|
|
|
ok_( ycm.FileParseRequestReady() )
|
|
@@ -271,12 +266,9 @@ def EventNotification_FileReadyToParse_NonDiagnostic_ConfirmExtraConf_test(
|
|
|
|
|
|
@YouCompleteMeInstance()
|
|
|
def EventNotification_FileReadyToParse_Diagnostic_Error_Native_test( ycm ):
|
|
|
- with MockArbitraryBuffer( 'cpp' ):
|
|
|
- _Check_FileReadyToParse_Diagnostic_Error( ycm )
|
|
|
- EmulateCurrentBufferChange()
|
|
|
- _Check_FileReadyToParse_Diagnostic_Warning( ycm )
|
|
|
- EmulateCurrentBufferChange()
|
|
|
- _Check_FileReadyToParse_Diagnostic_Clean( ycm )
|
|
|
+ _Check_FileReadyToParse_Diagnostic_Error( ycm )
|
|
|
+ _Check_FileReadyToParse_Diagnostic_Warning( ycm )
|
|
|
+ _Check_FileReadyToParse_Diagnostic_Clean( ycm )
|
|
|
|
|
|
|
|
|
@patch( 'vim.command' )
|
|
@@ -290,24 +282,24 @@ def _Check_FileReadyToParse_Diagnostic_Error( ycm, vim_command ):
|
|
|
diagnostic = Diagnostic( [], start, extent, 'expected ;', 'ERROR' )
|
|
|
return [ BuildDiagnosticData( diagnostic ) ]
|
|
|
|
|
|
- with MockEventNotification( DiagnosticResponse ):
|
|
|
- ycm.OnFileReadyToParse()
|
|
|
- ok_( ycm.FileParseRequestReady() )
|
|
|
- ycm.HandleFileParseRequest()
|
|
|
- vim_command.assert_has_calls( [
|
|
|
- PlaceSign_Call( 1, 1, 1, True )
|
|
|
- ] )
|
|
|
- eq_( ycm.GetErrorCount(), 1 )
|
|
|
- eq_( ycm.GetWarningCount(), 0 )
|
|
|
-
|
|
|
- # Consequent calls to HandleFileParseRequest shouldn't mess with
|
|
|
- # existing diagnostics, when there is no new parse request.
|
|
|
- vim_command.reset_mock()
|
|
|
- ok_( ycm.FileParseRequestReady() )
|
|
|
- ycm.HandleFileParseRequest()
|
|
|
- vim_command.assert_not_called()
|
|
|
- eq_( ycm.GetErrorCount(), 1 )
|
|
|
- eq_( ycm.GetWarningCount(), 0 )
|
|
|
+ with MockArbitraryBuffer( 'cpp' ):
|
|
|
+ with MockEventNotification( DiagnosticResponse ):
|
|
|
+ ycm.OnFileReadyToParse()
|
|
|
+ ok_( ycm.FileParseRequestReady() )
|
|
|
+ ycm.HandleFileParseRequest()
|
|
|
+ vim_command.assert_has_calls( [
|
|
|
+ PlaceSign_Call( 1, 1, 1, True )
|
|
|
+ ] )
|
|
|
+ eq_( ycm.GetErrorCount(), 1 )
|
|
|
+ eq_( ycm.GetWarningCount(), 0 )
|
|
|
+
|
|
|
+ # Consequent calls to HandleFileParseRequest shouldn't mess with
|
|
|
+ # existing diagnostics, when there is no new parse request.
|
|
|
+ vim_command.reset_mock()
|
|
|
+ ycm.HandleFileParseRequest()
|
|
|
+ vim_command.assert_not_called()
|
|
|
+ eq_( ycm.GetErrorCount(), 1 )
|
|
|
+ eq_( ycm.GetWarningCount(), 0 )
|
|
|
|
|
|
|
|
|
@patch( 'vim.command' )
|
|
@@ -322,25 +314,25 @@ def _Check_FileReadyToParse_Diagnostic_Warning( ycm, vim_command ):
|
|
|
diagnostic = Diagnostic( [], start, extent, 'cast', 'WARNING' )
|
|
|
return [ BuildDiagnosticData( diagnostic ) ]
|
|
|
|
|
|
- with MockEventNotification( DiagnosticResponse ):
|
|
|
- ycm.OnFileReadyToParse()
|
|
|
- ok_( ycm.FileParseRequestReady() )
|
|
|
- ycm.HandleFileParseRequest()
|
|
|
- vim_command.assert_has_calls( [
|
|
|
- PlaceSign_Call( 2, 2, 1, False ),
|
|
|
- UnplaceSign_Call( 1, 1 )
|
|
|
- ] )
|
|
|
- eq_( ycm.GetErrorCount(), 0 )
|
|
|
- eq_( ycm.GetWarningCount(), 1 )
|
|
|
-
|
|
|
- # Consequent calls to HandleFileParseRequest shouldn't mess with
|
|
|
- # existing diagnostics, when there is no new parse request.
|
|
|
- vim_command.reset_mock()
|
|
|
- ok_( ycm.FileParseRequestReady() )
|
|
|
- ycm.HandleFileParseRequest()
|
|
|
- vim_command.assert_not_called()
|
|
|
- eq_( ycm.GetErrorCount(), 0 )
|
|
|
- eq_( ycm.GetWarningCount(), 1 )
|
|
|
+ with MockArbitraryBuffer( 'cpp' ):
|
|
|
+ with MockEventNotification( DiagnosticResponse ):
|
|
|
+ ycm.OnFileReadyToParse()
|
|
|
+ ok_( ycm.FileParseRequestReady() )
|
|
|
+ ycm.HandleFileParseRequest()
|
|
|
+ vim_command.assert_has_calls( [
|
|
|
+ PlaceSign_Call( 2, 2, 1, False ),
|
|
|
+ UnplaceSign_Call( 1, 1 )
|
|
|
+ ] )
|
|
|
+ eq_( ycm.GetErrorCount(), 0 )
|
|
|
+ eq_( ycm.GetWarningCount(), 1 )
|
|
|
+
|
|
|
+ # Consequent calls to HandleFileParseRequest shouldn't mess with
|
|
|
+ # existing diagnostics, when there is no new parse request.
|
|
|
+ vim_command.reset_mock()
|
|
|
+ ycm.HandleFileParseRequest()
|
|
|
+ vim_command.assert_not_called()
|
|
|
+ eq_( ycm.GetErrorCount(), 0 )
|
|
|
+ eq_( ycm.GetWarningCount(), 1 )
|
|
|
|
|
|
|
|
|
@patch( 'vim.command' )
|
|
@@ -348,17 +340,20 @@ def _Check_FileReadyToParse_Diagnostic_Clean( ycm, vim_command ):
|
|
|
# Tests Vim sign unplacement and error/warning count python API
|
|
|
# when there are no errors/warnings left.
|
|
|
# Should be called after _Check_FileReadyToParse_Diagnostic_Warning
|
|
|
- with MockEventNotification( MagicMock( return_value = [] ) ):
|
|
|
- ycm.OnFileReadyToParse()
|
|
|
- ycm.HandleFileParseRequest()
|
|
|
- vim_command.assert_has_calls( [
|
|
|
- UnplaceSign_Call( 2, 1 )
|
|
|
- ] )
|
|
|
- eq_( ycm.GetErrorCount(), 0 )
|
|
|
- eq_( ycm.GetWarningCount(), 0 )
|
|
|
+ with MockArbitraryBuffer( 'cpp' ):
|
|
|
+ with MockEventNotification( MagicMock( return_value = [] ) ):
|
|
|
+ ycm.OnFileReadyToParse()
|
|
|
+ ycm.HandleFileParseRequest()
|
|
|
+ vim_command.assert_has_calls( [
|
|
|
+ UnplaceSign_Call( 2, 1 )
|
|
|
+ ] )
|
|
|
+ eq_( ycm.GetErrorCount(), 0 )
|
|
|
+ eq_( ycm.GetWarningCount(), 0 )
|
|
|
|
|
|
|
|
|
@patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
|
|
|
+@patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReadyWithCache',
|
|
|
+ return_value = True )
|
|
|
@YouCompleteMeInstance( { 'collect_identifiers_from_tags_files': 1 } )
|
|
|
def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
|
|
|
ycm, *args ):
|
|
@@ -372,9 +367,7 @@ def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
|
|
|
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
|
|
|
with CurrentWorkingDirectory( unicode_dir ):
|
|
|
with MockVimBuffers( [ current_buffer ], current_buffer, ( 6, 5 ) ):
|
|
|
- with patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReady',
|
|
|
- return_value = True ):
|
|
|
- ycm.OnFileReadyToParse()
|
|
|
+ ycm.OnFileReadyToParse()
|
|
|
|
|
|
assert_that(
|
|
|
# Positional arguments passed to PostDataToHandlerAsync.
|
|
@@ -505,6 +498,8 @@ def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test(
|
|
|
|
|
|
@patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
|
|
|
return_value = [ 'foo', 'bar' ] )
|
|
|
+@patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReadyWithCache',
|
|
|
+ return_value = True )
|
|
|
@YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
|
|
|
def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
|
|
|
ycm, *args ):
|
|
@@ -539,6 +534,8 @@ def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
|
|
|
|
|
|
@patch( 'ycm.syntax_parse.SyntaxKeywordsForCurrentBuffer',
|
|
|
return_value = [ 'foo', 'bar' ] )
|
|
|
+@patch( 'ycm.youcompleteme.YouCompleteMe.IsServerReadyWithCache',
|
|
|
+ return_value = True )
|
|
|
@YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
|
|
|
def EventNotification_FileReadyToParse_SyntaxKeywords_ClearCacheIfRestart_test(
|
|
|
ycm, *args ):
|