diff --git a/python/ycm/client/completion_request.py b/python/ycm/client/completion_request.py index ae754912..2c2ae455 100644 --- a/python/ycm/client/completion_request.py +++ b/python/ycm/client/completion_request.py @@ -48,7 +48,7 @@ class CompletionRequest( BaseRequest ): return bool( self._response_future ) and self._response_future.done() - def RawResponse( self ): + def _RawResponse( self ): if not self._response_future: return NO_COMPLETIONS @@ -71,7 +71,7 @@ class CompletionRequest( BaseRequest ): def Response( self ): - response = self.RawResponse() + response = self._RawResponse() response[ 'completions' ] = _ConvertCompletionDatasToVimDatas( response[ 'completions' ] ) return response @@ -96,11 +96,11 @@ class CompletionRequest( BaseRequest ): # completed item and the list of completions. Sometimes this returns # multiple possibilities, which is essentially unresolvable. if 'user_data' not in completed_item: - completions = self.RawResponse()[ 'completions' ] + completions = self._RawResponse()[ 'completions' ] return _FilterToMatchingCompletions( completed_item, completions ) if completed_item[ 'user_data' ]: - completions = self.RawResponse()[ 'completions' ] + completions = self._RawResponse()[ 'completions' ] return [ completions[ int( completed_item[ 'user_data' ] ) ] ] return [] diff --git a/python/ycm/client/omni_completion_request.py b/python/ycm/client/omni_completion_request.py index d27243cc..397ba212 100644 --- a/python/ycm/client/omni_completion_request.py +++ b/python/ycm/client/omni_completion_request.py @@ -39,15 +39,6 @@ class OmniCompletionRequest( CompletionRequest ): return True - def RawResponse( self ): - return { - 'line': self.request_data[ 'line_num' ], - 'column': self.request_data[ 'column_num' ], - 'completion_start_column': self.request_data[ 'start_column' ], - 'completions': _ConvertVimDatasToCompletionDatas( self._results ) - } - - def Response( self ): return { 'line': self.request_data[ 'line_num' ], @@ -57,24 +48,5 @@ class OmniCompletionRequest( CompletionRequest ): } -def ConvertVimDataToCompletionData( vim_data ): - # see :h complete-items for a description of the dictionary fields - completion_data = {} - - if 'word' in vim_data: - completion_data[ 'insertion_text' ] = vim_data[ 'word' ] - if 'abbr' in vim_data: - completion_data[ 'menu_text' ] = vim_data[ 'abbr' ] - if 'menu' in vim_data: - completion_data[ 'extra_menu_info' ] = vim_data[ 'menu' ] - if 'kind' in vim_data: - completion_data[ 'kind' ] = [ vim_data[ 'kind' ] ] - if 'info' in vim_data: - completion_data[ 'detailed_info' ] = vim_data[ 'info' ] - - return completion_data - - -def _ConvertVimDatasToCompletionDatas( response_data ): - return [ ConvertVimDataToCompletionData( x ) - for x in response_data ] + def OnCompleteDone( self ): + pass diff --git a/python/ycm/tests/client/omni_completion_request_tests.py b/python/ycm/tests/client/omni_completion_request_tests.py index d4ead04d..39c267b4 100644 --- a/python/ycm/tests/client/omni_completion_request_tests.py +++ b/python/ycm/tests/client/omni_completion_request_tests.py @@ -24,7 +24,6 @@ from builtins import * # noqa from mock import MagicMock from nose.tools import eq_ -from hamcrest import assert_that, has_entries from ycm.client.omni_completion_request import OmniCompletionRequest @@ -60,31 +59,3 @@ def Response_FromOmniCompleter_test(): 'completion_start_column': 1, 'completions': results } ) - - -def RawResponse_ConvertedFromOmniCompleter_test(): - vim_results = [ - { "word": "WORD", "abbr": "ABBR", "menu": "MENU", - "kind": "KIND", "info": "INFO" }, - { "word": "WORD2", "abbr": "ABBR2", "menu": "MENU2", - "kind": "KIND2", "info": "INFO" }, - { "word": "WORD", "abbr": "ABBR", }, - {}, - ] - expected_results = [ - has_entries( { "insertion_text": "WORD", "menu_text": "ABBR", - "extra_menu_info": "MENU", "kind": [ "KIND" ], - "detailed_info": "INFO" } ), - has_entries( { "insertion_text": "WORD2", "menu_text": "ABBR2", - "extra_menu_info": "MENU2", "kind": [ "KIND2" ], - "detailed_info": "INFO" } ), - has_entries( { "insertion_text": "WORD", "menu_text": "ABBR", } ), - has_entries( {} ), - ] - request = BuildOmnicompletionRequest( vim_results ) - - results = request.RawResponse()[ 'completions' ] - - eq_( len( results ), len( expected_results ) ) - for result, expected_result in zip( results, expected_results ): - assert_that( result, expected_result ) diff --git a/python/ycm/tests/postcomplete_test.py b/python/ycm/tests/postcomplete_test.py index f4fc9b6c..e1ee2623 100644 --- a/python/ycm/tests/postcomplete_test.py +++ b/python/ycm/tests/postcomplete_test.py @@ -36,6 +36,7 @@ from ycmd.utils import ToBytes from ycm.client.completion_request import ( CompletionRequest, _FilterToMatchingCompletions, _GetRequiredNamespaceImport ) +from ycm.client.omni_completion_request import OmniCompletionRequest def CompleteItemIs( word, abbr = None, menu = None, @@ -127,7 +128,7 @@ def _SetUpCompleteDone( completions ): with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' ): request = CompletionRequest( None ) request.Done = MagicMock( return_value = True ) - request.RawResponse = MagicMock( return_value = { + request._RawResponse = MagicMock( return_value = { 'completions': completions } ) yield request @@ -166,6 +167,17 @@ def OnCompleteDone_NoFixItIfNotDone_test( *args ): request._OnCompleteDone_FixIt.assert_not_called() +@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] ) +def OnCompleteDone_NoFixItForOmnifunc_test( *args ): + request = OmniCompletionRequest( 'omnifunc', None ) + request.Done = MagicMock( return_value = True ) + request._OnCompleteDone_Csharp = MagicMock() + request._OnCompleteDone_FixIt = MagicMock() + request.OnCompleteDone() + request._OnCompleteDone_Csharp.assert_not_called() + request._OnCompleteDone_FixIt.assert_not_called() + + def FilterToCompletedCompletions_MatchIsReturned_test(): completions = [ BuildCompletion( insertion_text = 'Test' ) ] result = _FilterToMatchingCompletions( CompleteItemIs( 'Test' ), completions )