Send extra_conf_vim_data in requests from :YcmCompleter and :YcmDebugInfo commands. It's needed for passing compile_commands.json directory to every call of FlagsForFile in client_data argument.

This commit is contained in:
Andrey Pikas 2017-03-11 12:59:21 +03:00
parent 650a19ba0a
commit 3db1413cd9
3 changed files with 18 additions and 8 deletions

View File

@ -36,16 +36,19 @@ def _EnsureBackwardsCompatibility( arguments ):
class CommandRequest( BaseRequest ): class CommandRequest( BaseRequest ):
def __init__( self, arguments, completer_target = None ): def __init__( self, arguments, completer_target = None, extra_data = None ):
super( CommandRequest, self ).__init__() super( CommandRequest, self ).__init__()
self._arguments = _EnsureBackwardsCompatibility( arguments ) self._arguments = _EnsureBackwardsCompatibility( arguments )
self._completer_target = ( completer_target if completer_target self._completer_target = ( completer_target if completer_target
else 'filetype_default' ) else 'filetype_default' )
self._extra_data = extra_data
self._response = None self._response = None
def Start( self ): def Start( self ):
request_data = BuildRequestData() request_data = BuildRequestData()
if self._extra_data:
request_data.update( self._extra_data )
request_data.update( { request_data.update( {
'completer_target': self._completer_target, 'completer_target': self._completer_target,
'command_arguments': self._arguments 'command_arguments': self._arguments
@ -129,8 +132,8 @@ class CommandRequest( BaseRequest ):
vimsupport.WriteToPreviewWindow( self._response[ 'detailed_info' ] ) vimsupport.WriteToPreviewWindow( self._response[ 'detailed_info' ] )
def SendCommandRequest( arguments, completer ): def SendCommandRequest( arguments, completer, extra_data = None ):
request = CommandRequest( arguments, completer ) request = CommandRequest( arguments, completer, extra_data )
# This is a blocking call. # This is a blocking call.
request.Start() request.Start()
request.RunPostCommandActionsIfNeeded() request.RunPostCommandActionsIfNeeded()

View File

@ -28,13 +28,16 @@ from ycm.client.base_request import ( BaseRequest, BuildRequestData,
class DebugInfoRequest( BaseRequest ): class DebugInfoRequest( BaseRequest ):
def __init__( self ): def __init__( self, extra_data = None ):
super( DebugInfoRequest, self ).__init__() super( DebugInfoRequest, self ).__init__()
self._extra_data = extra_data
self._response = None self._response = None
def Start( self ): def Start( self ):
request_data = BuildRequestData() request_data = BuildRequestData()
if self._extra_data:
request_data.update( self._extra_data )
with HandleServerException( display = False ): with HandleServerException( display = False ):
self._response = self.PostDataToHandler( request_data, 'debug_info' ) self._response = self.PostDataToHandler( request_data, 'debug_info' )
@ -111,8 +114,8 @@ def _FormatCompleterDebugInfo( completer ):
return message return message
def SendDebugInfoRequest(): def SendDebugInfoRequest( extra_data = None ):
request = DebugInfoRequest() request = DebugInfoRequest( extra_data )
# This is a blocking call. # This is a blocking call.
request.Start() request.Start()
return request.Response() return request.Response()

View File

@ -302,7 +302,9 @@ class YouCompleteMe( object ):
def SendCommandRequest( self, arguments, completer ): def SendCommandRequest( self, arguments, completer ):
return SendCommandRequest( arguments, completer ) extra_data = {}
self._AddExtraConfDataIfNeeded( extra_data )
return SendCommandRequest( arguments, completer, extra_data )
def GetDefinedSubcommands( self ): def GetDefinedSubcommands( self ):
@ -636,7 +638,9 @@ class YouCompleteMe( object ):
debug_info = '' debug_info = ''
if self._client_logfile: if self._client_logfile:
debug_info += 'Client logfile: {0}\n'.format( self._client_logfile ) debug_info += 'Client logfile: {0}\n'.format( self._client_logfile )
debug_info += FormatDebugInfoResponse( SendDebugInfoRequest() ) extra_data = {}
self._AddExtraConfDataIfNeeded( extra_data )
debug_info += FormatDebugInfoResponse( SendDebugInfoRequest( extra_data ) )
debug_info += ( debug_info += (
'Server running at: {0}\n' 'Server running at: {0}\n'
'Server process ID: {1}\n'.format( BaseRequest.server_location, 'Server process ID: {1}\n'.format( BaseRequest.server_location,