async def _run(self) -> int:
    while True:
        async with _read_lsp_request(self.input_channel, self.output_channel) as request:
            LOG.debug(f'Received LSP request: {log.truncate(str(request), 400)}')
            if (request.method == 'exit'):
                return commands.ExitCode.FAILURE
            elif (request.method == 'shutdown'):
                (await lsp.write_json_rpc(self.output_channel, json_rpc.SuccessResponse(id=request.id, result=None)))
                return (await self.wait_for_exit())
            elif (request.method == 'textDocument/didOpen'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didOpen method')
                (await self.process_open_request(lsp.DidOpenTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/didClose'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didClose method')
                (await self.process_close_request(lsp.DidCloseTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/didSave'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didSave method')
                (await self.process_did_save_request(lsp.DidSaveTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/hover'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for hover method')
                (await self.process_hover_request(lsp.HoverTextDocumentParameters.from_json_rpc_parameters(parameters), request.id))
            elif (request.method == 'textDocument/typeCoverage'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for typeCoverage method')
                (await self.process_type_coverage_request(lsp.TypeCoverageTextDocumentParameters.from_json_rpc_parameters(parameters), request.id))
            elif (request.id is not None):
                raise lsp.RequestCancelledError('Request not supported yet')
async def _run(self) -> int:
    while True:
        async with _read_lsp_request(self.input_channel, self.output_channel) as request:
            LOG.debug(f'Received LSP request: {log.truncate(str(request), 400)}')
            if (request.method == 'exit'):
                return commands.ExitCode.FAILURE
            elif (request.method == 'shutdown'):
                (await lsp.write_json_rpc(self.output_channel, json_rpc.SuccessResponse(id=request.id, result=None)))
                return (await self.wait_for_exit())
            elif (request.method == 'textDocument/didOpen'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didOpen method')
                (await self.process_open_request(lsp.DidOpenTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/didClose'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didClose method')
                (await self.process_close_request(lsp.DidCloseTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/didSave'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for didSave method')
                (await self.process_did_save_request(lsp.DidSaveTextDocumentParameters.from_json_rpc_parameters(parameters)))
            elif (request.method == 'textDocument/hover'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for hover method')
                (await self.process_hover_request(lsp.HoverTextDocumentParameters.from_json_rpc_parameters(parameters), request.id))
            elif (request.method == 'textDocument/typeCoverage'):
                parameters = request.parameters
                if (parameters is None):
                    raise json_rpc.InvalidRequestError('Missing parameters for typeCoverage method')
                (await self.process_type_coverage_request(lsp.TypeCoverageTextDocumentParameters.from_json_rpc_parameters(parameters), request.id))
            elif (request.id is not None):
                raise lsp.RequestCancelledError('Request not supported yet')