Auto merge of #3275 - micbou:complete-done-omnifunc, r=bstaletic
[READY] Do not apply fixits for omnifunc completion Fixes #3274. <!-- 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/3275) <!-- Reviewable:end -->
This commit is contained in:
commit
a53ccefca9
@ -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 []
|
||||
|
@ -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
|
||||
|
@ -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 )
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user