From 3ca758a581ea8f20d506ef0248cbfb8525143f17 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 27 Sep 2013 17:13:43 -0700 Subject: [PATCH] Getting debug info works again --- python/ycm/completers/completer.py | 2 +- python/ycm/completers/cpp/clang_completer.py | 7 +++---- python/ycm/server/responses.py | 2 ++ python/ycm/server/ycmd.py | 20 +++++++++++++++++++ python/ycm/youcompleteme.py | 21 ++------------------ 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/python/ycm/completers/completer.py b/python/ycm/completers/completer.py index c66b7564..7bf055f9 100644 --- a/python/ycm/completers/completer.py +++ b/python/ycm/completers/completer.py @@ -319,7 +319,7 @@ class Completer( object ): pass - def DebugInfo( self ): + def DebugInfo( self, request_data ): return '' diff --git a/python/ycm/completers/cpp/clang_completer.py b/python/ycm/completers/cpp/clang_completer.py index 5aebae8e..339379ce 100644 --- a/python/ycm/completers/cpp/clang_completer.py +++ b/python/ycm/completers/cpp/clang_completer.py @@ -319,10 +319,9 @@ class ClangCompleter( Completer ): return '' flags = self._FlagsForRequest( request_data ) or [] source = extra_conf_store.ModuleFileForSourceFile( filename ) - return responses.BuildDisplayMessageResponse( - 'Flags for {0} loaded from {1}:\n{2}'.format( filename, - source, - list( flags ) ) ) + return 'Flags for {0} loaded from {1}:\n{2}'.format( filename, + source, + list( flags ) ) def _FlagsForRequest( self, request_data ): filename = request_data[ 'filepath' ] diff --git a/python/ycm/server/responses.py b/python/ycm/server/responses.py index 37a2afd4..450106d9 100644 --- a/python/ycm/server/responses.py +++ b/python/ycm/server/responses.py @@ -38,6 +38,8 @@ def BuildDescriptionOnlyGoToResponse( text ): } +# TODO: Look at all the callers and ensure they are not using this instead of an +# exception. def BuildDisplayMessageResponse( text ): return { 'message': text diff --git a/python/ycm/server/ycmd.py b/python/ycm/server/ycmd.py index 4b27dd63..609243d7 100755 --- a/python/ycm/server/ycmd.py +++ b/python/ycm/server/ycmd.py @@ -128,6 +128,26 @@ def DefinedSubcommands(): return _JsonResponse( completer.DefinedSubcommands() ) +@app.post( '/debug_info') +def DebugInfo(): + # This can't be at the top level because of possible extra conf preload + import ycm_core + LOGGER.info( 'Received debug info request') + + output = [] + has_clang_support = ycm_core.HasClangSupport() + output.append( 'Server has Clang support compiled in: {0}'.format( + has_clang_support ) ) + + if has_clang_support: + output.append( ycm_core.ClangVersion() ) + + request_data = request.json + output.append( + _GetCompleterForRequestData( request_data ).DebugInfo( request_data) ) + return _JsonResponse( '\n'.join( output ) ) + + # The type of the param is Bottle.HTTPError @app.error( httplib.INTERNAL_SERVER_ERROR ) def ErrorHandler( httperror ): diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 0e0009d6..44146ec1 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -19,7 +19,6 @@ import os import vim -import ycm_core import subprocess import tempfile import json @@ -203,24 +202,8 @@ class YouCompleteMe( object ): def DebugInfo( self ): - completers = set( self._filetype_completers.values() ) - completers.add( self._gencomp ) - output = [] - for completer in completers: - if not completer: - continue - debug = completer.DebugInfo() - if debug: - output.append( debug ) - - has_clang_support = ycm_core.HasClangSupport() - output.append( 'Has Clang support compiled in: {0}'.format( - has_clang_support ) ) - - if has_clang_support: - output.append( ycm_core.ClangVersion() ) - - return '\n'.join( output ) + return BaseRequest.PostDataToHandler( BuildRequestData(), + 'debug_info' ) def CurrentFiletypeCompletionEnabled( self ):