Browse Source

Remove knowlegde from YCM about subcommand names

Now 'GoTo' and 'FixIt' commands don't need to start with those
prefixes. For 'FixIt' we can detect the response type by looking for
the 'fixits' entry in the response.

For 'GoTo' this is a touch harder, as there is no completely obvious
way to tell. However it is unique in this respect, so we can simply
fall back to it.

Completers returning other types of response are not supported by
this client.
Ben Jackson 9 years ago
parent
commit
d9fef6be14
1 changed files with 8 additions and 10 deletions
  1. 8 10
      python/ycm/client/command_request.py

+ 8 - 10
python/ycm/client/command_request.py

@@ -33,10 +33,6 @@ class CommandRequest( BaseRequest ):
     self._arguments = _EnsureBackwardsCompatibility( arguments )
     self._completer_target = ( completer_target if completer_target
                                else 'filetype_default' )
-    self._is_goto_command = (
-        self._arguments and self._arguments[ 0 ].startswith( 'GoTo' ) )
-    self._is_fixit_command = (
-        self._arguments and self._arguments[ 0 ].startswith( 'FixIt' ) )
     self._response = None
 
 
@@ -61,24 +57,26 @@ class CommandRequest( BaseRequest ):
     if not self.Done() or self._response is None:
       return
 
-    if self._is_goto_command:
-      return self._HandleGotoResponse()
-
-    if self._is_fixit_command:
-      return self._HandleFixitResponse()
-
     # If not a dictionary or a list, the response is necessarily a
     # scalar: boolean, number, string, etc. In this case, we print
     # it to the user.
     if not isinstance( self._response, ( dict, list ) ):
       return self._HandleBasicResponse()
 
+    if 'fixits' in self._response:
+      return self._HandleFixitResponse()
+
     if 'message' in self._response:
       return self._HandleMessageResponse()
 
     if 'detailed_info' in self._response:
       return self._HandleDetailedInfoResponse()
 
+    # The only other type of response we understand is GoTo, and that is the
+    # only one that we can't detect just by inspecting the response (it should
+    # either be a single location or a list)
+    return self._HandleGotoResponse()
+
 
   def _HandleGotoResponse( self ):
     if isinstance( self._response, list ):