diff --git a/ycmd/completers/language_server/language_server_completer.py b/ycmd/completers/language_server/language_server_completer.py index 5ece249330..c6426dd196 100644 --- a/ycmd/completers/language_server/language_server_completer.py +++ b/ycmd/completers/language_server/language_server_completer.py @@ -25,7 +25,6 @@ import logging import threading -import socket import json import os import queue @@ -230,136 +229,6 @@ def _Read( self, size=-1 ): raise RuntimeError( 'Not implemented' ) - -class TCPSingleStreamServer( LanguageServerConnection, threading.Thread ): - def __init__( self, port ): - super( TCPSingleStreamServer, self ).__init__() - - self._port = port - self._socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - self._client_socket = None - - - def run( self ): - self._socket.bind( ( 'localhost', self._port ) ) - self._socket.listen( 0 ) - - self._run_loop() - - - def _TryServerConnectionBlocking( self ): - ( self._client_socket, _ ) = self._socket.accept() - _logger.info( 'language server socket connected' ) - - return True - - - def _Write( self, data ): - assert self._connection_event.isSet() - assert self._client_socket - - total_sent = 0 - while total_sent < len( data ): - sent = self._client_socket.send( data[ total_sent: ] ) - if sent == 0: - raise RuntimeError( 'write socket failed' ) - - total_sent += sent - - - def _Read( self, size=-1 ): - assert self._connection_event.isSet() - assert self._client_socket - - if size < 0: - data = self._client_socket.recv( 2048 ) - if data == '': - raise RuntimeError( 'read socket failed' ) - - return data - - chunks = [] - bytes_read = 0 - while bytes_read < size: - chunk = self._client_socket.recv( min( size - bytes_read , 2048 ) ) - if chunk == '': - raise RuntimeError( 'read socket failed' ) - - chunks.append( chunk ) - bytes_read += len( chunk ) - - return utils.ToBytes( '' ).join( chunks ) - - -class TCPMultiStreamServer( LanguageServerConnection, threading.Thread ): - def __init__( self, input_port, output_port ): - super( TCPMultiStreamServer, self ).__init__() - - self._connection_event = threading.Event() - - self._input_port = input_port - self._input_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - - self._output_port = output_port - self._output_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - - self._client_read_socket = None - self._client_write_socket = None - - - def run( self ): - self._input_socket.bind( ( 'localhost', self._input_port ) ) - self._input_socket.listen( 0 ) - - self._output_socket.bind( ( 'localhost', self._output_port ) ) - self._output_socket.listen( 0 ) - - self._run_loop() - - - def _TryServerConnectionBlocking( self ): - ( self._client_read_socket, _ ) = self._input_socket.accept() - _logger.info( 'Language server Input socket connected' ) - - ( self._client_write_socket, _ ) = self._output_socket.accept() - _logger.info( 'Language server Output socket connected' ) - - - def _Write( self, data ): - assert self._client_write_socket - - total_sent = 0 - while total_sent < len( data ): - sent = self._client_write_socket.send( data[ total_sent: ] ) - if sent == 0: - raise RuntimeError( 'write socket failed' ) - - total_sent += sent - - - def _Read( self, size=-1 ): - assert self._client_read_socket - - if size < 0: - data = self._client_read_socket.recv( 2048 ) - if data == '': - raise RuntimeError( 'read socket failed' ) - - return data - - chunks = [] - bytes_read = 0 - while bytes_read < size: - chunk = self._client_read_socket.recv( min( size - bytes_read , 2048 ) ) - if chunk == '': - raise RuntimeError( 'read socket failed' ) - - chunks.append( chunk ) - bytes_read += len( chunk ) - - return utils.ToBytes( '' ).join( chunks ) - - class StandardIOLanguageServerConnection( LanguageServerConnection, threading.Thread ): def __init__( self, server_stdin, server_stdout ):