2014-01-13 14:08:43 -05:00
|
|
|
# Copyright (C) 2013 Google Inc.
|
2013-10-07 18:47:48 -04:00
|
|
|
#
|
|
|
|
# This file is part of YouCompleteMe.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-02-19 14:02:58 -05:00
|
|
|
from ycmd.utils import ToBytes
|
2013-10-07 18:47:48 -04:00
|
|
|
from ycm.client.completion_request import CompletionRequest
|
|
|
|
|
|
|
|
|
|
|
|
class OmniCompletionRequest( CompletionRequest ):
|
2014-05-28 03:05:50 -04:00
|
|
|
def __init__( self, omni_completer, request_data ):
|
2014-05-28 13:20:54 -04:00
|
|
|
super( OmniCompletionRequest, self ).__init__( request_data )
|
2013-10-07 18:47:48 -04:00
|
|
|
self._omni_completer = omni_completer
|
|
|
|
|
|
|
|
|
2014-05-27 17:29:19 -04:00
|
|
|
def Start( self ):
|
2013-10-07 18:47:48 -04:00
|
|
|
self._results = self._omni_completer.ComputeCandidates( self.request_data )
|
|
|
|
|
|
|
|
|
|
|
|
def Done( self ):
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2015-12-31 18:14:26 -05:00
|
|
|
def RawResponse( self ):
|
|
|
|
return _ConvertVimDatasToCompletionDatas( self._results )
|
|
|
|
|
|
|
|
|
2013-10-07 18:47:48 -04:00
|
|
|
def Response( self ):
|
|
|
|
return self._results
|
2015-12-31 18:14:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
def ConvertVimDataToCompletionData( vim_data ):
|
|
|
|
# see :h complete-items for a description of the dictionary fields
|
|
|
|
completion_data = {}
|
|
|
|
|
|
|
|
if 'word' in vim_data:
|
2016-02-19 14:02:58 -05:00
|
|
|
completion_data[ 'insertion_text' ] = ToBytes( vim_data[ 'word' ] )
|
2015-12-31 18:14:26 -05:00
|
|
|
if 'abbr' in vim_data:
|
2016-02-19 14:02:58 -05:00
|
|
|
completion_data[ 'menu_text' ] = ToBytes( vim_data[ 'abbr' ] )
|
2015-12-31 18:14:26 -05:00
|
|
|
if 'menu' in vim_data:
|
2016-02-19 14:02:58 -05:00
|
|
|
completion_data[ 'extra_menu_info' ] = ToBytes( vim_data[ 'menu' ] )
|
2015-12-31 18:14:26 -05:00
|
|
|
if 'kind' in vim_data:
|
2016-02-19 14:02:58 -05:00
|
|
|
completion_data[ 'kind' ] = [ ToBytes( vim_data[ 'kind' ] ) ]
|
2015-12-31 18:14:26 -05:00
|
|
|
if 'info' in vim_data:
|
2016-02-19 14:02:58 -05:00
|
|
|
completion_data[ 'detailed_info' ] = ToBytes( vim_data[ 'info' ] )
|
2015-12-31 18:14:26 -05:00
|
|
|
|
|
|
|
return completion_data
|
|
|
|
|
|
|
|
|
|
|
|
def _ConvertVimDatasToCompletionDatas( response_data ):
|
|
|
|
return [ ConvertVimDataToCompletionData( x )
|
|
|
|
for x in response_data ]
|