Skip to content

Commit

Permalink
Remove ServerTerminated in C♯ completer
Browse files Browse the repository at this point in the history
ServerTerminated is the inverse of ServerIsActive so we remove one
and use the other instead.
  • Loading branch information
micbou committed Jan 17, 2016
1 parent c801620 commit d6595b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
29 changes: 12 additions & 17 deletions ycmd/completers/cs/cs_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@ def GetSubcommandsMap( self ):
'GetDoc' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = '_GetDoc' ) ),
'ServerIsActive' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = 'ServerIsActive',
no_request_data = True ) ),
'ServerRunning' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = 'ServerIsRunning',
no_request_data = True ) ),
'ServerReady' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = 'ServerIsReady',
no_request_data = True ) ),
'ServerTerminated' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = 'ServerTerminated',
no_request_data = True ) )
}

Expand Down Expand Up @@ -300,6 +300,12 @@ def DebugInfo( self, request_data ):
return 'OmniSharp Server is not running'


def ServerIsActive( self, request_data = None ):
""" Check if the server process has already terminated. """
return self._CheckSingleOrAllActive( request_data,
lambda i: i.ServerIsActive() )


def ServerIsRunning( self, request_data = None ):
""" Check if our OmniSharp server is running. """
return self._CheckSingleOrAllActive( request_data,
Expand All @@ -312,12 +318,6 @@ def ServerIsReady( self, request_data = None ):
lambda i: i.ServerIsReady() )


def ServerTerminated( self, request_data = None ):
""" Check if the server process has already terminated. """
return self._CheckSingleOrAllActive( request_data,
lambda i: i.ServerTerminated() )


def _CheckSingleOrAllActive( self, request_data, action ):
if request_data is not None:
solutioncompleter = self._GetSolutionCompleter( request_data )
Expand Down Expand Up @@ -409,7 +409,7 @@ def _StopServer( self ):
self._TryToStopServer()

# Kill it if it's still up
if not self.ServerTerminated() and self._omnisharp_phandle is not None:
if self.ServerIsActive():
self._logger.info( 'Killing OmniSharp server' )
self._omnisharp_phandle.kill()

Expand All @@ -425,7 +425,7 @@ def _TryToStopServer( self ):
except:
pass
for _ in range( 10 ):
if self.ServerTerminated():
if not self.ServerIsActive():
return
time.sleep( .1 )

Expand Down Expand Up @@ -580,11 +580,6 @@ def ServerIsReady( self ):
return False


def ServerTerminated( self ):
""" Check if the server process has already terminated. """
return not utils.ProcessIsRunning( self._omnisharp_phandle )


def _SolutionFile( self ):
""" Find out which solution file server was started with """
return self._solution_path
Expand Down
4 changes: 2 additions & 2 deletions ycmd/tests/cs/cs_handlers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def _WaitUntilOmniSharpServerReady( self, filename ):
success = True
break
request = self._BuildRequest( completer_target = 'filetype_default',
command_arguments = [ 'ServerTerminated' ],
command_arguments = [ 'ServerIsActive' ],
filepath = filename,
filetype = 'cs' )
result = self._app.post_json( '/run_completer_command', request ).json
if result:
if not result:
raise RuntimeError( "OmniSharp failed during startup." )
time.sleep( 0.2 )
retries = retries - 1
Expand Down

0 comments on commit d6595b7

Please sign in to comment.