From d9fef6be14dff13542a2ecabf7e17d30907dd12d Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Mon, 11 Jan 2016 23:33:15 +0000 Subject: [PATCH] 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. --- python/ycm/client/command_request.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index 75685669..dc6abfb1 100644 --- a/python/ycm/client/command_request.py +++ b/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 ):