From 2d9c41f52723e6473166caf4cfcebae5b231301b Mon Sep 17 00:00:00 2001 From: "Spencer G. Jones" Date: Tue, 28 Jan 2014 10:31:45 -0700 Subject: [PATCH] Expose OmniSharp's ReloadSolution command --- python/ycm/completers/cs/cs_completer.py | 7 ++++ .../ycm/server/tests/get_completions_test.py | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index 4ec15e98..4194ac0f 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -43,6 +43,7 @@ class CsharpCompleter( Completer ): 'StartServer': (lambda self, request_data: self._StartServer( request_data )), 'StopServer': (lambda self, request_data: self._StopServer()), 'RestartServer': (lambda self, request_data: self._RestartServer( request_data )), + 'ReloadSolution': (lambda self, request_data: self._ReloadSolution()), 'ServerRunning': (lambda self, request_data: self._ServerIsRunning()), 'ServerReady': (lambda self, request_data: self._ServerIsReady()), 'GoToDefinition': (lambda self, request_data: self._GoToDefinition( request_data )), @@ -183,6 +184,12 @@ class CsharpCompleter( Completer ): return self._StartServer( request_data ) + def _ReloadSolution( self ): + """ Reloads the solutions in the OmniSharp server """ + self._logger.info( 'Reloading Solution in OmniSharp server' ) + return self._GetResponse( '/reloadsolution' ) + + def _GetCompletions( self, request_data ): """ Ask server for completions """ completions = self._GetResponse( '/autocomplete', diff --git a/python/ycm/server/tests/get_completions_test.py b/python/ycm/server/tests/get_completions_test.py index 55e267d5..b92be09e 100644 --- a/python/ycm/server/tests/get_completions_test.py +++ b/python/ycm/server/tests/get_completions_test.py @@ -96,6 +96,42 @@ def GetCompletions_CsCompleter_Works_test(): command_arguments = ['StopServer'], filetype = 'cs' ) ) +@with_setup( Setup ) +def GetCompletions_CsCompleter_ReloadSolutionWorks_test(): + app = TestApp( handlers.app ) + filepath = PathToTestFile( 'testy/Program.cs' ) + contents = open( filepath ).read() + event_data = BuildRequest( filepath = filepath, + filetype = 'cs', + contents = contents, + event_name = 'FileReadyToParse' ) + + app.post_json( '/event_notification', event_data ) + + # We need to wait until the server has started up. + while True: + result = app.post_json( '/run_completer_command', + BuildRequest( completer_target = 'filetype_default', + command_arguments = ['ServerReady'], + filetype = 'cs' ) ).json + if result: + break + time.sleep( 0.2 ) + + + result = app.post_json( '/run_completer_command', + BuildRequest( completer_target = 'filetype_default', + command_arguments = ['ReloadSolution'], + filetype = 'cs' ) ).json + + eq_(result, True) + + # We need to turn off the CS server so that it doesn't stick around + app.post_json( '/run_completer_command', + BuildRequest( completer_target = 'filetype_default', + command_arguments = ['StopServer'], + filetype = 'cs' ) ) + @with_setup( Setup ) def GetCompletions_CsCompleter_StartsWithUnambiguousMultipleSolutions_test(): app = TestApp( handlers.app )