|
@@ -36,27 +36,43 @@ from ycm import vimsupport
|
|
|
from ycm.tests import YouCompleteMeInstance
|
|
|
from ycmd.utils import ToBytes
|
|
|
|
|
|
+from ycm.youcompleteme import _CompleteDoneHook_CSharp
|
|
|
+from ycm.youcompleteme import _CompleteDoneHook_Java
|
|
|
+
|
|
|
+
|
|
|
+def CompleteItemIs( word, abbr = None, menu = None,
|
|
|
+ info = None, kind = None, **kwargs ):
|
|
|
+ item = {
|
|
|
+ 'word': ToBytes( word ),
|
|
|
+ 'abbr': ToBytes( abbr ),
|
|
|
+ 'menu': ToBytes( menu ),
|
|
|
+ 'info': ToBytes( info ),
|
|
|
+ 'kind': ToBytes( kind ),
|
|
|
+ }
|
|
|
+ item.update( **kwargs )
|
|
|
+ return item
|
|
|
+
|
|
|
|
|
|
def GetVariableValue_CompleteItemIs( word, abbr = None, menu = None,
|
|
|
- info = None, kind = None ):
|
|
|
+ info = None, kind = None, **kwargs ):
|
|
|
def Result( variable ):
|
|
|
if variable == 'v:completed_item':
|
|
|
- return {
|
|
|
- 'word': ToBytes( word ),
|
|
|
- 'abbr': ToBytes( abbr ),
|
|
|
- 'menu': ToBytes( menu ),
|
|
|
- 'info': ToBytes( info ),
|
|
|
- 'kind': ToBytes( kind ),
|
|
|
- }
|
|
|
+ return CompleteItemIs( word, abbr, menu, info, kind, **kwargs )
|
|
|
return DEFAULT
|
|
|
return MagicMock( side_effect = Result )
|
|
|
|
|
|
|
|
|
-def BuildCompletion( namespace = None, insertion_text = 'Test',
|
|
|
- menu_text = None, extra_menu_info = None,
|
|
|
- detailed_info = None, kind = None ):
|
|
|
+def BuildCompletion( insertion_text = 'Test',
|
|
|
+ menu_text = None,
|
|
|
+ extra_menu_info = None,
|
|
|
+ detailed_info = None,
|
|
|
+ kind = None,
|
|
|
+ extra_data = None ):
|
|
|
+ if extra_data is None:
|
|
|
+ extra_data = {}
|
|
|
+
|
|
|
return {
|
|
|
- 'extra_data': { 'required_namespace_import': namespace },
|
|
|
+ 'extra_data': extra_data,
|
|
|
'insertion_text': insertion_text,
|
|
|
'menu_text': menu_text,
|
|
|
'extra_menu_info': extra_menu_info,
|
|
@@ -65,141 +81,191 @@ def BuildCompletion( namespace = None, insertion_text = 'Test',
|
|
|
}
|
|
|
|
|
|
|
|
|
+def BuildCompletionNamespace( namespace = None,
|
|
|
+ insertion_text = 'Test',
|
|
|
+ menu_text = None,
|
|
|
+ extra_menu_info = None,
|
|
|
+ detailed_info = None,
|
|
|
+ kind = None ):
|
|
|
+ return BuildCompletion( insertion_text = insertion_text,
|
|
|
+ menu_text = menu_text,
|
|
|
+ extra_menu_info = extra_menu_info,
|
|
|
+ detailed_info = detailed_info,
|
|
|
+ kind = kind,
|
|
|
+ extra_data = {
|
|
|
+ 'required_namespace_import': namespace
|
|
|
+ } )
|
|
|
+
|
|
|
+
|
|
|
+def BuildCompletionFixIt( fixits,
|
|
|
+ insertion_text = 'Test',
|
|
|
+ menu_text = None,
|
|
|
+ extra_menu_info = None,
|
|
|
+ detailed_info = None,
|
|
|
+ kind = None ):
|
|
|
+ return BuildCompletion( insertion_text = insertion_text,
|
|
|
+ menu_text = menu_text,
|
|
|
+ extra_menu_info = extra_menu_info,
|
|
|
+ detailed_info = detailed_info,
|
|
|
+ kind = kind,
|
|
|
+ extra_data = {
|
|
|
+ 'fixits': fixits,
|
|
|
+ } )
|
|
|
+
|
|
|
+
|
|
|
@contextlib.contextmanager
|
|
|
def _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
with patch( 'ycm.vimsupport.InsertNamespace' ):
|
|
|
- with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' ):
|
|
|
- request = MagicMock()
|
|
|
- request.Done = MagicMock( return_value = True )
|
|
|
- request.RawResponse = MagicMock( return_value = completions )
|
|
|
- ycm._latest_completion_request = request
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
yield
|
|
|
|
|
|
|
|
|
+@contextlib.contextmanager
|
|
|
+def _SetUpCompleteDone( ycm, completions ):
|
|
|
+ with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' ):
|
|
|
+ request = MagicMock()
|
|
|
+ request.Done = MagicMock( return_value = True )
|
|
|
+ request.RawResponse = MagicMock( return_value = {
|
|
|
+ 'completions': completions
|
|
|
+ } )
|
|
|
+ ycm._latest_completion_request = request
|
|
|
+ yield
|
|
|
+
|
|
|
+
|
|
|
@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'cs' ] )
|
|
|
@YouCompleteMeInstance()
|
|
|
def GetCompleteDoneHooks_ResultOnCsharp_test( ycm, *args ):
|
|
|
- result = ycm.GetCompleteDoneHooks()
|
|
|
- eq_( 1, len( list( result ) ) )
|
|
|
+ result = list( ycm.GetCompleteDoneHooks() )
|
|
|
+ eq_( [ _CompleteDoneHook_CSharp ], result )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'txt' ] )
|
|
|
+@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'java' ] )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def GetCompleteDoneHooks_ResultOnJava_test( ycm, *args ):
|
|
|
+ result = list( ycm.GetCompleteDoneHooks() )
|
|
|
+ eq_( [ _CompleteDoneHook_Java ], result )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] )
|
|
|
@YouCompleteMeInstance()
|
|
|
def GetCompleteDoneHooks_EmptyOnOtherFiletype_test( ycm, *args ):
|
|
|
result = ycm.GetCompleteDoneHooks()
|
|
|
eq_( 0, len( list( result ) ) )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'txt' ] )
|
|
|
+@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] )
|
|
|
@YouCompleteMeInstance()
|
|
|
def OnCompleteDone_WithActionCallsIt_test( ycm, *args ):
|
|
|
action = MagicMock()
|
|
|
- ycm._complete_done_hooks[ 'txt' ] = action
|
|
|
+ ycm._complete_done_hooks[ 'ycmtest' ] = action
|
|
|
ycm.OnCompleteDone()
|
|
|
ok_( action.called )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'txt' ] )
|
|
|
+@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] )
|
|
|
@YouCompleteMeInstance()
|
|
|
def OnCompleteDone_NoActionNoError_test( ycm, *args ):
|
|
|
- ycm.OnCompleteDone()
|
|
|
+ with patch.object( ycm, '_OnCompleteDone_Csharp' ) as csharp:
|
|
|
+ with patch.object( ycm, '_OnCompleteDone_Java' ) as java:
|
|
|
+ ycm.OnCompleteDone()
|
|
|
+ csharp.assert_not_called()
|
|
|
+ java.assert_not_called()
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def FilterToCompletedCompletions_MatchIsReturned_test( ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
|
|
- result = ycm._FilterToMatchingCompletions( completions, False )
|
|
|
+ result = ycm._FilterToMatchingCompletions( CompleteItemIs( 'Test' ),
|
|
|
+ completions,
|
|
|
+ False )
|
|
|
eq_( list( result ), completions )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'A' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def FilterToCompletedCompletions_ShortTextDoesntRaise_test( ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'AAA' ) ]
|
|
|
- ycm._FilterToMatchingCompletions( completions, False )
|
|
|
+ ycm._FilterToMatchingCompletions( CompleteItemIs( 'A' ),
|
|
|
+ completions,
|
|
|
+ False )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def FilterToCompletedCompletions_ExactMatchIsReturned_test( ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
|
|
- result = ycm._FilterToMatchingCompletions( completions, False )
|
|
|
+ result = ycm._FilterToMatchingCompletions( CompleteItemIs( 'Test' ),
|
|
|
+ completions,
|
|
|
+ False )
|
|
|
eq_( list( result ), completions )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( ' Quote' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def FilterToCompletedCompletions_NonMatchIsntReturned_test( ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'A' ) ]
|
|
|
- result = ycm._FilterToMatchingCompletions( completions, False )
|
|
|
+ result = ycm._FilterToMatchingCompletions( CompleteItemIs( ' Quote' ),
|
|
|
+ completions,
|
|
|
+ False )
|
|
|
assert_that( list( result ), empty() )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( '†es†' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def FilterToCompletedCompletions_Unicode_test( ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = '†es†' ) ]
|
|
|
- result = ycm._FilterToMatchingCompletions( completions, False )
|
|
|
+ result = ycm._FilterToMatchingCompletions( CompleteItemIs( '†es†' ),
|
|
|
+ completions,
|
|
|
+ False )
|
|
|
eq_( list( result ), completions )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'Te' ) )
|
|
|
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
|
|
|
@YouCompleteMeInstance()
|
|
|
def HasCompletionsThatCouldBeCompletedWithMoreText_MatchIsReturned_test(
|
|
|
ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
|
|
- result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
|
|
|
+ result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText(
|
|
|
+ CompleteItemIs( 'Te' ),
|
|
|
+ completions )
|
|
|
eq_( result, True )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'X' ) )
|
|
|
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
|
|
|
@YouCompleteMeInstance()
|
|
|
def HasCompletionsThatCouldBeCompletedWithMoreText_ShortTextDoesntRaise_test(
|
|
|
ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'AAA' ) ]
|
|
|
- ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
|
|
|
+ ycm._HasCompletionsThatCouldBeCompletedWithMoreText( CompleteItemIs( 'X' ),
|
|
|
+ completions )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
|
|
|
@YouCompleteMeInstance()
|
|
|
def HasCompletionsThatCouldBeCompletedWithMoreText_ExactMatchIsntReturned_test(
|
|
|
ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
|
|
- result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
|
|
|
+ result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText(
|
|
|
+ CompleteItemIs( 'Test' ),
|
|
|
+ completions )
|
|
|
eq_( result, False )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( ' Quote' ) )
|
|
|
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
|
|
|
@YouCompleteMeInstance()
|
|
|
def HasCompletionsThatCouldBeCompletedWithMoreText_NonMatchIsntReturned_test(
|
|
|
ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = "A" ) ]
|
|
|
- result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
|
|
|
+ result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText(
|
|
|
+ CompleteItemIs( ' Quote' ),
|
|
|
+ completions )
|
|
|
eq_( result, False )
|
|
|
|
|
|
|
|
|
-@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
- GetVariableValue_CompleteItemIs( 'Uniç' ) )
|
|
|
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Uniç' )
|
|
|
@YouCompleteMeInstance()
|
|
|
def HasCompletionsThatCouldBeCompletedWithMoreText_Unicode_test(
|
|
|
ycm, *args ):
|
|
|
completions = [ BuildCompletion( insertion_text = 'Uniçø∂¢' ) ]
|
|
|
- result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
|
|
|
+ result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText(
|
|
|
+ CompleteItemIs( 'Uniç' ),
|
|
|
+ completions )
|
|
|
eq_( result, True )
|
|
|
|
|
|
|
|
@@ -212,7 +278,7 @@ def GetRequiredNamespaceImport_ReturnNoneForNoExtraData_test( ycm ):
|
|
|
def GetRequiredNamespaceImport_ReturnNamespaceFromExtraData_test( ycm ):
|
|
|
namespace = 'A_NAMESPACE'
|
|
|
eq_( namespace, ycm._GetRequiredNamespaceImport(
|
|
|
- BuildCompletion( namespace )
|
|
|
+ BuildCompletionNamespace( namespace )
|
|
|
) )
|
|
|
|
|
|
|
|
@@ -228,7 +294,7 @@ def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfNotDone_test( ycm ):
|
|
|
@YouCompleteMeInstance()
|
|
|
def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfPendingMatches_test(
|
|
|
ycm, *args ):
|
|
|
- completions = [ BuildCompletion( None ) ]
|
|
|
+ completions = [ BuildCompletionNamespace( None ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
eq_( [], ycm.GetCompletionsUserMayHaveCompleted() )
|
|
|
|
|
@@ -237,7 +303,7 @@ def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfPendingMatches_test(
|
|
|
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatches_test(
|
|
|
ycm, *args ):
|
|
|
info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ]
|
|
|
- completions = [ BuildCompletion( *info ) ]
|
|
|
+ completions = [ BuildCompletionNamespace( *info ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
with patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
GetVariableValue_CompleteItemIs( *info[ 1: ] ) ):
|
|
@@ -248,7 +314,7 @@ def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatches_test(
|
|
|
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatchesEvenIfPartial_test( # noqa
|
|
|
ycm, *args ):
|
|
|
info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ]
|
|
|
- completions = [ BuildCompletion( *info ),
|
|
|
+ completions = [ BuildCompletionNamespace( *info ),
|
|
|
BuildCompletion( insertion_text = 'TestTest' ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
with patch( 'ycm.vimsupport.GetVariableValue',
|
|
@@ -272,11 +338,41 @@ def GetCompletionsUserMayHaveCompleted_DontReturnMatchIfNoExactMatchesAndPartial
|
|
|
GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
@YouCompleteMeInstance()
|
|
|
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfMatches_test( ycm, *args ):
|
|
|
- completions = [ BuildCompletion( None ) ]
|
|
|
+ completions = [ BuildCompletionNamespace( None ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() )
|
|
|
|
|
|
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test', user_data='0' ) )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def GetCompletionsUserMayHaveCompleted_UseUserData0_test( ycm, *args ):
|
|
|
+ # identical completions but we specify the first one via user_data
|
|
|
+ completions = [
|
|
|
+ BuildCompletionNamespace( 'namespace1' ),
|
|
|
+ BuildCompletionNamespace( 'namespace2' )
|
|
|
+ ]
|
|
|
+
|
|
|
+ with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
+ eq_( [ BuildCompletionNamespace( 'namespace1' ) ],
|
|
|
+ ycm.GetCompletionsUserMayHaveCompleted() )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test', user_data='1' ) )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def GetCompletionsUserMayHaveCompleted_UseUserData1_test( ycm, *args ):
|
|
|
+ # identical completions but we specify the second one via user_data
|
|
|
+ completions = [
|
|
|
+ BuildCompletionNamespace( 'namespace1' ),
|
|
|
+ BuildCompletionNamespace( 'namespace2' )
|
|
|
+ ]
|
|
|
+
|
|
|
+ with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
+ eq_( [ BuildCompletionNamespace( 'namespace2' ) ],
|
|
|
+ ycm.GetCompletionsUserMayHaveCompleted() )
|
|
|
+
|
|
|
+
|
|
|
@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
@YouCompleteMeInstance()
|
|
@@ -291,7 +387,7 @@ def PostCompleteCsharp_EmptyDoesntInsertNamespace_test( ycm, *args ):
|
|
|
@YouCompleteMeInstance()
|
|
|
def PostCompleteCsharp_ExistingWithoutNamespaceDoesntInsertNamespace_test(
|
|
|
ycm, *args ):
|
|
|
- completions = [ BuildCompletion( None ) ]
|
|
|
+ completions = [ BuildCompletionNamespace( None ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
ycm._OnCompleteDone_Csharp()
|
|
|
ok_( not vimsupport.InsertNamespace.called )
|
|
@@ -302,7 +398,7 @@ def PostCompleteCsharp_ExistingWithoutNamespaceDoesntInsertNamespace_test(
|
|
|
@YouCompleteMeInstance()
|
|
|
def PostCompleteCsharp_ValueDoesInsertNamespace_test( ycm, *args ):
|
|
|
namespace = 'A_NAMESPACE'
|
|
|
- completions = [ BuildCompletion( namespace ) ]
|
|
|
+ completions = [ BuildCompletionNamespace( namespace ) ]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
ycm._OnCompleteDone_Csharp()
|
|
|
vimsupport.InsertNamespace.assert_called_once_with( namespace )
|
|
@@ -316,9 +412,92 @@ def PostCompleteCsharp_InsertSecondNamespaceIfSelected_test( ycm, *args ):
|
|
|
namespace = 'A_NAMESPACE'
|
|
|
namespace2 = 'ANOTHER_NAMESPACE'
|
|
|
completions = [
|
|
|
- BuildCompletion( namespace ),
|
|
|
- BuildCompletion( namespace2 ),
|
|
|
+ BuildCompletionNamespace( namespace ),
|
|
|
+ BuildCompletionNamespace( namespace2 ),
|
|
|
]
|
|
|
with _SetupForCsharpCompletionDone( ycm, completions ):
|
|
|
ycm._OnCompleteDone_Csharp()
|
|
|
vimsupport.InsertNamespace.assert_called_once_with( namespace2 )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_NoFixIts_test( ycm, replace_chunks, *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletionFixIt( [] )
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_not_called()
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_EmptyFixIt_test( ycm, replace_chunks, *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': [] } ] )
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_called_once_with( [], silent=True )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_NoFixIt_test( ycm, replace_chunks, *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletion( )
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_not_called()
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_PickFirst_test( ycm, replace_chunks, *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'one' } ] ),
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'two' } ] ),
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_called_once_with( 'one', silent=True )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test', user_data='0' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_PickFirstUserData_test( ycm,
|
|
|
+ replace_chunks,
|
|
|
+ *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'one' } ] ),
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'two' } ] ),
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_called_once_with( 'one', silent=True )
|
|
|
+
|
|
|
+
|
|
|
+@patch( 'ycm.vimsupport.GetVariableValue',
|
|
|
+ GetVariableValue_CompleteItemIs( 'Test', user_data='1' ) )
|
|
|
+@patch( 'ycm.vimsupport.ReplaceChunks' )
|
|
|
+@YouCompleteMeInstance()
|
|
|
+def PostCompleteJava_ApplyFixIt_PickSecond_test( ycm, replace_chunks, *args ):
|
|
|
+ completions = [
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'one' } ] ),
|
|
|
+ BuildCompletionFixIt( [ { 'chunks': 'two' } ] ),
|
|
|
+ ]
|
|
|
+ with _SetUpCompleteDone( ycm, completions ):
|
|
|
+ ycm._OnCompleteDone_Java()
|
|
|
+ replace_chunks.assert_called_once_with( 'two', silent=True )
|