Auto merge of #2650 - micbou:clean-cs-inserting-namespace-code, r=bstaletic

[READY] Clean C# inserting namespace code

Now that we require at least Vim 7.4.1578, we can remove the code that automatically insert namespaces in C# for Vim versions prior to 7.4.774.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2650)
<!-- Reviewable:end -->
This commit is contained in:
zzbot 2017-05-19 19:19:34 -07:00 committed by GitHub
commit 263bd88bd5
3 changed files with 24 additions and 220 deletions

View File

@ -105,204 +105,98 @@ def OnCompleteDone_NoActionNoError_test( ycm, *args ):
ycm.OnCompleteDone() ycm.OnCompleteDone()
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) ) GetVariableValue_CompleteItemIs( 'Test' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def FilterToCompletedCompletions_NewVim_MatchIsReturned_test( ycm, *args ): def FilterToCompletedCompletions_MatchIsReturned_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ] completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._FilterToMatchingCompletions( completions, False ) result = ycm._FilterToMatchingCompletions( completions, False )
eq_( list( result ), completions ) eq_( list( result ), completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'A' ) ) GetVariableValue_CompleteItemIs( 'A' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def FilterToCompletedCompletions_NewVim_ShortTextDoesntRaise_test( ycm, *args ): def FilterToCompletedCompletions_ShortTextDoesntRaise_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'AAA' ) ] completions = [ BuildCompletion( insertion_text = 'AAA' ) ]
ycm._FilterToMatchingCompletions( completions, False ) ycm._FilterToMatchingCompletions( completions, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) ) GetVariableValue_CompleteItemIs( 'Test' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def FilterToCompletedCompletions_NewVim_ExactMatchIsReturned_test( ycm, *args ): def FilterToCompletedCompletions_ExactMatchIsReturned_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ] completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._FilterToMatchingCompletions( completions, False ) result = ycm._FilterToMatchingCompletions( completions, False )
eq_( list( result ), completions ) eq_( list( result ), completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( ' Quote' ) ) GetVariableValue_CompleteItemIs( ' Quote' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def FilterToCompletedCompletions_NewVim_NonMatchIsntReturned_test( ycm, *args ): def FilterToCompletedCompletions_NonMatchIsntReturned_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'A' ) ] completions = [ BuildCompletion( insertion_text = 'A' ) ]
result = ycm._FilterToMatchingCompletions( completions, False ) result = ycm._FilterToMatchingCompletions( completions, False )
assert_that( list( result ), empty() ) assert_that( list( result ), empty() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( '†es†' ) ) GetVariableValue_CompleteItemIs( '†es†' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def FilterToCompletedCompletions_NewVim_Unicode_test( ycm, *args ): def FilterToCompletedCompletions_Unicode_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = '†es†' ) ] completions = [ BuildCompletion( insertion_text = '†es†' ) ]
result = ycm._FilterToMatchingCompletions( completions, False ) result = ycm._FilterToMatchingCompletions( completions, False )
eq_( list( result ), completions ) eq_( list( result ), completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' )
@YouCompleteMeInstance()
def FilterToCompletedCompletions_OldVim_MatchIsReturned_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._FilterToMatchingCompletions( completions, False )
eq_( list( result ), completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'X' )
@YouCompleteMeInstance()
def FilterToCompletedCompletions_OldVim_ShortTextDoesntRaise_test( ycm,
*args ):
completions = [ BuildCompletion( insertion_text = 'AAA' ) ]
ycm._FilterToMatchingCompletions( completions, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Test' )
@YouCompleteMeInstance()
def FilterToCompletedCompletions_OldVim_ExactMatchIsReturned_test( ycm,
*args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._FilterToMatchingCompletions( completions, False )
eq_( list( result ), completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance()
def FilterToCompletedCompletions_OldVim_NonMatchIsntReturned_test( ycm,
*args ):
completions = [ BuildCompletion( insertion_text = 'A' ) ]
result = ycm._FilterToMatchingCompletions( completions, False )
assert_that( list( result ), empty() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Uniçø∂¢' )
@YouCompleteMeInstance()
def FilterToCompletedCompletions_OldVim_Unicode_test( ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Uniçø∂¢' ) ]
result = ycm._FilterToMatchingCompletions( completions, False )
assert_that( list( result ), empty() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Te' )
@YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_MatchIsReturned_test( # noqa
ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, True )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'X' )
@YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_ShortTextDoesntRaise_test( # noqa
ycm, *args ):
completions = [ BuildCompletion( insertion_text = "AAA" ) ]
ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Test' )
@YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_ExactMatchIsntReturned_test( # noqa
ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_NonMatchIsntReturned_test( # noqa
ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'A' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Uniç' )
@YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_Unicode_test(
ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Uniçø∂¢' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, True )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Te' ) ) GetVariableValue_CompleteItemIs( 'Te' ) )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' ) @patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_MatchIsReturned_test( # noqa def HasCompletionsThatCouldBeCompletedWithMoreText_MatchIsReturned_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ] completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions ) result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, True ) eq_( result, True )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'X' ) ) GetVariableValue_CompleteItemIs( 'X' ) )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' ) @patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_ShortTextDoesntRaise_test( # noqa def HasCompletionsThatCouldBeCompletedWithMoreText_ShortTextDoesntRaise_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'AAA' ) ] completions = [ BuildCompletion( insertion_text = 'AAA' ) ]
ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions ) ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) ) GetVariableValue_CompleteItemIs( 'Test' ) )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' ) @patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_ExactMatchIsntReturned_test( # noqa def HasCompletionsThatCouldBeCompletedWithMoreText_ExactMatchIsntReturned_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Test' ) ] completions = [ BuildCompletion( insertion_text = 'Test' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions ) result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, False ) eq_( result, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( ' Quote' ) ) GetVariableValue_CompleteItemIs( ' Quote' ) )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' ) @patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Quote' )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_NonMatchIsntReturned_test( # noqa def HasCompletionsThatCouldBeCompletedWithMoreText_NonMatchIsntReturned_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( insertion_text = "A" ) ] completions = [ BuildCompletion( insertion_text = "A" ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions ) result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
eq_( result, False ) eq_( result, False )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Uniç' ) ) GetVariableValue_CompleteItemIs( 'Uniç' ) )
@patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Uniç' ) @patch( 'ycm.vimsupport.TextBeforeCursor', return_value = 'Uniç' )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_Unicode_test( def HasCompletionsThatCouldBeCompletedWithMoreText_Unicode_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( insertion_text = 'Uniçø∂¢' ) ] completions = [ BuildCompletion( insertion_text = 'Uniçø∂¢' ) ]
result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions ) result = ycm._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
@ -329,30 +223,18 @@ def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfNotDone_test( ycm ):
eq_( [], ycm.GetCompletionsUserMayHaveCompleted() ) eq_( [], ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Te' ) ) GetVariableValue_CompleteItemIs( 'Te' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfPendingMatches_NewVim_test( # noqa def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfPendingMatches_test(
ycm, *args ): ycm, *args ):
completions = [ BuildCompletion( None ) ] completions = [ BuildCompletion( None ) ]
with _SetupForCsharpCompletionDone( ycm, completions ): with _SetupForCsharpCompletionDone( ycm, completions ):
eq_( [], ycm.GetCompletionsUserMayHaveCompleted() ) eq_( [], ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_ReturnEmptyIfPendingMatches_OldVim_test( # noqa def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatches_test(
ycm, *args ):
completions = [ BuildCompletion( None ) ]
with _SetupForCsharpCompletionDone( ycm, completions ):
with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Te' ):
eq_( [], ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatches_NewVim_test(
ycm, *args ): ycm, *args ):
info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ] info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ]
completions = [ BuildCompletion( *info ) ] completions = [ BuildCompletion( *info ) ]
@ -362,9 +244,8 @@ def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatches_NewVim_test(
eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() ) eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatchesEvenIfPartial_NewVim_test( # noqa def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatchesEvenIfPartial_test( # noqa
ycm, *args ): ycm, *args ):
info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ] info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ]
completions = [ BuildCompletion( *info ), completions = [ BuildCompletion( *info ),
@ -375,9 +256,8 @@ def GetCompletionsUserMayHaveCompleted_ReturnMatchIfExactMatchesEvenIfPartial_Ne
eq_( [ completions[ 0 ] ], ycm.GetCompletionsUserMayHaveCompleted() ) eq_( [ completions[ 0 ] ], ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_DontReturnMatchIfNontExactMatchesAndPartial_NewVim_test( # noqa def GetCompletionsUserMayHaveCompleted_DontReturnMatchIfNoExactMatchesAndPartial_test( # noqa
ycm, *args ): ycm, *args ):
info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ] info = [ 'NS', 'Test', 'Abbr', 'Menu', 'Info', 'Kind' ]
completions = [ BuildCompletion( insertion_text = info[ 0 ] ), completions = [ BuildCompletion( insertion_text = info[ 0 ] ),
@ -388,27 +268,17 @@ def GetCompletionsUserMayHaveCompleted_DontReturnMatchIfNontExactMatchesAndParti
eq_( [], ycm.GetCompletionsUserMayHaveCompleted() ) eq_( [], ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = True )
@patch( 'ycm.vimsupport.GetVariableValue', @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) ) GetVariableValue_CompleteItemIs( 'Test' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfMatches_NewVim_test( def GetCompletionsUserMayHaveCompleted_ReturnMatchIfMatches_test( ycm, *args ):
ycm, *args ):
completions = [ BuildCompletion( None ) ] completions = [ BuildCompletion( None ) ]
with _SetupForCsharpCompletionDone( ycm, completions ): with _SetupForCsharpCompletionDone( ycm, completions ):
eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() ) eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False ) @patch( 'ycm.vimsupport.GetVariableValue',
@YouCompleteMeInstance() GetVariableValue_CompleteItemIs( 'Test' ) )
def GetCompletionsUserMayHaveCompleted_ReturnMatchIfMatches_OldVim_test(
ycm, *args ):
completions = [ BuildCompletion( None ) ]
with _SetupForCsharpCompletionDone( ycm, completions ):
eq_( completions, ycm.GetCompletionsUserMayHaveCompleted() )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def PostCompleteCsharp_EmptyDoesntInsertNamespace_test( ycm, *args ): def PostCompleteCsharp_EmptyDoesntInsertNamespace_test( ycm, *args ):
with _SetupForCsharpCompletionDone( ycm, [] ): with _SetupForCsharpCompletionDone( ycm, [] ):
@ -416,7 +286,8 @@ def PostCompleteCsharp_EmptyDoesntInsertNamespace_test( ycm, *args ):
ok_( not vimsupport.InsertNamespace.called ) ok_( not vimsupport.InsertNamespace.called )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False ) @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def PostCompleteCsharp_ExistingWithoutNamespaceDoesntInsertNamespace_test( def PostCompleteCsharp_ExistingWithoutNamespaceDoesntInsertNamespace_test(
ycm, *args ): ycm, *args ):
@ -426,7 +297,8 @@ def PostCompleteCsharp_ExistingWithoutNamespaceDoesntInsertNamespace_test(
ok_( not vimsupport.InsertNamespace.called ) ok_( not vimsupport.InsertNamespace.called )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False ) @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def PostCompleteCsharp_ValueDoesInsertNamespace_test( ycm, *args ): def PostCompleteCsharp_ValueDoesInsertNamespace_test( ycm, *args ):
namespace = 'A_NAMESPACE' namespace = 'A_NAMESPACE'
@ -436,7 +308,8 @@ def PostCompleteCsharp_ValueDoesInsertNamespace_test( ycm, *args ):
vimsupport.InsertNamespace.assert_called_once_with( namespace ) vimsupport.InsertNamespace.assert_called_once_with( namespace )
@patch( 'ycm.vimsupport.VimVersionAtLeast', return_value = False ) @patch( 'ycm.vimsupport.GetVariableValue',
GetVariableValue_CompleteItemIs( 'Test' ) )
@patch( 'ycm.vimsupport.PresentDialog', return_value = 1 ) @patch( 'ycm.vimsupport.PresentDialog', return_value = 1 )
@YouCompleteMeInstance() @YouCompleteMeInstance()
def PostCompleteCsharp_InsertSecondNamespaceIfSelected_test( ycm, *args ): def PostCompleteCsharp_InsertSecondNamespaceIfSelected_test( ycm, *args ):

View File

@ -83,19 +83,6 @@ def TextBeforeCursor():
return ToUnicode( vim.current.line[ :CurrentColumn() ] ) return ToUnicode( vim.current.line[ :CurrentColumn() ] )
# Expects version_string in 'MAJOR.MINOR.PATCH' format, e.g. '7.4.301'
def VimVersionAtLeast( version_string ):
major, minor, patch = [ int( x ) for x in version_string.split( '.' ) ]
# For Vim 7.4.301, v:version is '704'
actual_major_and_minor = GetIntValue( 'v:version' )
matching_major_and_minor = major * 100 + minor
if actual_major_and_minor != matching_major_and_minor:
return actual_major_and_minor > matching_major_and_minor
return GetBoolValue( 'has("patch{0}")'.format( patch ) )
# Note the difference between buffer OPTIONS and VARIABLES; the two are not # Note the difference between buffer OPTIONS and VARIABLES; the two are not
# the same. # the same.
def GetBufferOption( buffer_object, option ): def GetBufferOption( buffer_object, option ):

View File

@ -28,7 +28,6 @@ import base64
import json import json
import logging import logging
import os import os
import re
import signal import signal
import vim import vim
from subprocess import PIPE from subprocess import PIPE
@ -442,31 +441,6 @@ class YouCompleteMe( object ):
def _FilterToMatchingCompletions( self, completions, full_match_only ): def _FilterToMatchingCompletions( self, completions, full_match_only ):
self._PatchBasedOnVimVersion()
return self._FilterToMatchingCompletions( completions, full_match_only)
def _HasCompletionsThatCouldBeCompletedWithMoreText( self, completions ):
self._PatchBasedOnVimVersion()
return self._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
def _PatchBasedOnVimVersion( self ):
if vimsupport.VimVersionAtLeast( "7.4.774" ):
self._HasCompletionsThatCouldBeCompletedWithMoreText = \
self._HasCompletionsThatCouldBeCompletedWithMoreText_NewerVim
self._FilterToMatchingCompletions = \
self._FilterToMatchingCompletions_NewerVim
else:
self._FilterToMatchingCompletions = \
self._FilterToMatchingCompletions_OlderVim
self._HasCompletionsThatCouldBeCompletedWithMoreText = \
self._HasCompletionsThatCouldBeCompletedWithMoreText_OlderVim
def _FilterToMatchingCompletions_NewerVim( self,
completions,
full_match_only ):
"""Filter to completions matching the item Vim said was completed""" """Filter to completions matching the item Vim said was completed"""
completed = vimsupport.GetVariableValue( 'v:completed_item' ) completed = vimsupport.GetVariableValue( 'v:completed_item' )
for completion in completions: for completion in completions:
@ -482,24 +456,7 @@ class YouCompleteMe( object ):
yield completion yield completion
def _FilterToMatchingCompletions_OlderVim( self, completions, def _HasCompletionsThatCouldBeCompletedWithMoreText( self, completions ):
full_match_only ):
""" Filter to completions matching the buffer text """
if full_match_only:
return # Only supported in 7.4.774+
# No support for multiple line completions
text = vimsupport.TextBeforeCursor()
for completion in completions:
word = completion[ "insertion_text" ]
# Trim complete-ending character if needed
text = re.sub( r"[^a-zA-Z0-9_]$", "", text )
buffer_text = text[ -1 * len( word ) : ]
if buffer_text == word:
yield completion
def _HasCompletionsThatCouldBeCompletedWithMoreText_NewerVim( self,
completions ):
completed_item = vimsupport.GetVariableValue( 'v:completed_item' ) completed_item = vimsupport.GetVariableValue( 'v:completed_item' )
if not completed_item: if not completed_item:
return False return False
@ -526,19 +483,6 @@ class YouCompleteMe( object ):
return False return False
def _HasCompletionsThatCouldBeCompletedWithMoreText_OlderVim( self,
completions ):
# No support for multiple line completions
text = vimsupport.TextBeforeCursor()
for completion in completions:
word = utils.ToUnicode(
ConvertCompletionDataToVimData( completion )[ 'word' ] )
for i in range( 1, len( word ) - 1 ): # Excluding full word
if text[ -1 * i : ] == word[ : i ]:
return True
return False
def _OnCompleteDone_Csharp( self ): def _OnCompleteDone_Csharp( self ):
completions = self.GetCompletionsUserMayHaveCompleted() completions = self.GetCompletionsUserMayHaveCompleted()
namespaces = [ self._GetRequiredNamespaceImport( c ) namespaces = [ self._GetRequiredNamespaceImport( c )