浏览代码

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.

Andrey Pikas 8 年之前
父节点
当前提交
3db1413cd9
共有 3 个文件被更改,包括 18 次插入8 次删除
  1. 6 3
      python/ycm/client/command_request.py
  2. 6 3
      python/ycm/client/debug_info_request.py
  3. 6 2
      python/ycm/youcompleteme.py

+ 6 - 3
python/ycm/client/command_request.py

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

+ 6 - 3
python/ycm/client/debug_info_request.py

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

+ 6 - 2
python/ycm/youcompleteme.py

@@ -302,7 +302,9 @@ class YouCompleteMe( object ):
 
 
   def SendCommandRequest( self, arguments, completer ):
-    return SendCommandRequest( arguments, completer )
+    extra_data = {}
+    self._AddExtraConfDataIfNeeded( extra_data )
+    return SendCommandRequest( arguments, completer, extra_data )
 
 
   def GetDefinedSubcommands( self ):
@@ -636,7 +638,9 @@ class YouCompleteMe( object ):
     debug_info = ''
     if 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 += (
       'Server running at: {0}\n'
       'Server process ID: {1}\n'.format( BaseRequest.server_location,