Do not apply fixits for omnifunc completion
This commit is contained in:
parent
0790dc99b4
commit
9091454d18
@ -48,7 +48,7 @@ class CompletionRequest( BaseRequest ):
|
|||||||
return bool( self._response_future ) and self._response_future.done()
|
return bool( self._response_future ) and self._response_future.done()
|
||||||
|
|
||||||
|
|
||||||
def RawResponse( self ):
|
def _RawResponse( self ):
|
||||||
if not self._response_future:
|
if not self._response_future:
|
||||||
return NO_COMPLETIONS
|
return NO_COMPLETIONS
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class CompletionRequest( BaseRequest ):
|
|||||||
|
|
||||||
|
|
||||||
def Response( self ):
|
def Response( self ):
|
||||||
response = self.RawResponse()
|
response = self._RawResponse()
|
||||||
response[ 'completions' ] = _ConvertCompletionDatasToVimDatas(
|
response[ 'completions' ] = _ConvertCompletionDatasToVimDatas(
|
||||||
response[ 'completions' ] )
|
response[ 'completions' ] )
|
||||||
return response
|
return response
|
||||||
@ -96,11 +96,11 @@ class CompletionRequest( BaseRequest ):
|
|||||||
# completed item and the list of completions. Sometimes this returns
|
# completed item and the list of completions. Sometimes this returns
|
||||||
# multiple possibilities, which is essentially unresolvable.
|
# multiple possibilities, which is essentially unresolvable.
|
||||||
if 'user_data' not in completed_item:
|
if 'user_data' not in completed_item:
|
||||||
completions = self.RawResponse()[ 'completions' ]
|
completions = self._RawResponse()[ 'completions' ]
|
||||||
return _FilterToMatchingCompletions( completed_item, completions )
|
return _FilterToMatchingCompletions( completed_item, completions )
|
||||||
|
|
||||||
if completed_item[ 'user_data' ]:
|
if completed_item[ 'user_data' ]:
|
||||||
completions = self.RawResponse()[ 'completions' ]
|
completions = self._RawResponse()[ 'completions' ]
|
||||||
return [ completions[ int( completed_item[ 'user_data' ] ) ] ]
|
return [ completions[ int( completed_item[ 'user_data' ] ) ] ]
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
@ -39,15 +39,6 @@ class OmniCompletionRequest( CompletionRequest ):
|
|||||||
return True
|
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 ):
|
def Response( self ):
|
||||||
return {
|
return {
|
||||||
'line': self.request_data[ 'line_num' ],
|
'line': self.request_data[ 'line_num' ],
|
||||||
@ -57,24 +48,5 @@ class OmniCompletionRequest( CompletionRequest ):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def ConvertVimDataToCompletionData( vim_data ):
|
def OnCompleteDone( self ):
|
||||||
# see :h complete-items for a description of the dictionary fields
|
pass
|
||||||
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 ]
|
|
||||||
|
@ -24,7 +24,6 @@ from builtins import * # noqa
|
|||||||
|
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
from nose.tools import eq_
|
from nose.tools import eq_
|
||||||
from hamcrest import assert_that, has_entries
|
|
||||||
|
|
||||||
from ycm.client.omni_completion_request import OmniCompletionRequest
|
from ycm.client.omni_completion_request import OmniCompletionRequest
|
||||||
|
|
||||||
@ -60,31 +59,3 @@ def Response_FromOmniCompleter_test():
|
|||||||
'completion_start_column': 1,
|
'completion_start_column': 1,
|
||||||
'completions': results
|
'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 )
|
|
||||||
|
@ -36,6 +36,7 @@ from ycmd.utils import ToBytes
|
|||||||
from ycm.client.completion_request import ( CompletionRequest,
|
from ycm.client.completion_request import ( CompletionRequest,
|
||||||
_FilterToMatchingCompletions,
|
_FilterToMatchingCompletions,
|
||||||
_GetRequiredNamespaceImport )
|
_GetRequiredNamespaceImport )
|
||||||
|
from ycm.client.omni_completion_request import OmniCompletionRequest
|
||||||
|
|
||||||
|
|
||||||
def CompleteItemIs( word, abbr = None, menu = None,
|
def CompleteItemIs( word, abbr = None, menu = None,
|
||||||
@ -127,7 +128,7 @@ def _SetUpCompleteDone( completions ):
|
|||||||
with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' ):
|
with patch( 'ycm.vimsupport.TextBeforeCursor', return_value = ' Test' ):
|
||||||
request = CompletionRequest( None )
|
request = CompletionRequest( None )
|
||||||
request.Done = MagicMock( return_value = True )
|
request.Done = MagicMock( return_value = True )
|
||||||
request.RawResponse = MagicMock( return_value = {
|
request._RawResponse = MagicMock( return_value = {
|
||||||
'completions': completions
|
'completions': completions
|
||||||
} )
|
} )
|
||||||
yield request
|
yield request
|
||||||
@ -166,6 +167,17 @@ def OnCompleteDone_NoFixItIfNotDone_test( *args ):
|
|||||||
request._OnCompleteDone_FixIt.assert_not_called()
|
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():
|
def FilterToCompletedCompletions_MatchIsReturned_test():
|
||||||
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
completions = [ BuildCompletion( insertion_text = 'Test' ) ]
|
||||||
result = _FilterToMatchingCompletions( CompleteItemIs( 'Test' ), completions )
|
result = _FilterToMatchingCompletions( CompleteItemIs( 'Test' ), completions )
|
||||||
|
Loading…
Reference in New Issue
Block a user