In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see for more information.

Commit 7836ab9e authored by eckhart's avatar eckhart

DHParser/templates/DSLServer.pyi updated, so it reflects latest changes in...

DHParser/templates/DSLServer.pyi updated, so it reflects latest changes in examples/EBNF/
parent a245e118
......@@ -92,7 +92,9 @@ __all__ = ('RPC_Table',
......@@ -101,6 +103,7 @@ __all__ = ('RPC_Table',
......@@ -172,8 +175,11 @@ USE_DEFAULT_PORT = -1
IDENTIFY_REQUEST = "identify()"
LOGGING_REQUEST = "logging('')"
def substitute_default_host_and_port(host, port):
"""Substiutes the default value(s) from the configuration file if host
......@@ -582,7 +588,7 @@ class Connection:
elif method == 'exit':
self.lsp_shutdown = LSP_SHUTDOWN
self.lsp_initialized = ''
elif strict and method != STOP_SERVER_REQUEST:
elif strict and method not in (STOP_SERVER_REQUEST, IDENTIFY_REQUEST):
if self.lsp_shutdown:
return -32600, 'language server already shut down'
elif self.lsp_initialized != LSP_INITIALIZED:
......@@ -616,7 +622,7 @@ class Server:
:param rpc_table: Table mapping LSP-method names to Python functions
:param known_methods: Set of all known LSP-methods. This includes the
methods in the rpc-table and the four initialization methods,
`initialize()`, `initialized()`, `shudown()`, `exit`
`initialize()`, `initialized()`, `shutdown()`, `exit`
:param connection_callback: A callback function that is called with the
connection object as argument when a connection to a client is
......@@ -968,7 +974,6 @@ class Server:
elif method_name not in self.known_methods: # self.rpc_table:
rpc_error = -32601, 'Method not found: ' + str(json_obj['method'])
elif method_name in self.rpc_table:
# method_name = json_obj['method']
method = self.rpc_table[method_name]
params = json_obj['params'] if 'params' in json_obj else {}
if service_call:
......@@ -1163,8 +1168,11 @@ class Server:
if rpc_error is None:
if isinstance(raw, Dict):
json_obj = cast(JSON_Dict, raw)
raw_id = cast(Union[str, int], json_obj.get('id', gen_task_id()))
json_id = int(raw_id)
raw_id = json_obj.get('id', gen_task_id())
json_id = int(raw_id)
except TypeError:
json_id = 0
rpc_error = -32700, 'Parse error: JSON-package does not appear '\
'to ba an RPC-call or -response!?'
......@@ -1339,6 +1347,22 @@ def run_server(host, port, rpc_functions: RPC_Type,
server.run_server(host, port)
async def probe_server(host, port, timeout=SERVER_REPLY_TIMEOUT) -> str:
"""Connects to server and sends an identify-request. Returns the response
or an empty string if connection failed or command timed out."""
reader, writer = await asyncio.open_connection(host, port)
# request = b'{"jsonrpc": "2.0", "method": "identify", "params": [], "id": null}'
ident = await asyncio.wait_for('max_rpc_size')), timeout)
return ident.decode()
except asyncio.TimeoutError:
return ''
except ConnectionRefusedError:
return ''
def dummy_server(s: str) -> str:
return s
......@@ -43,7 +43,7 @@ except ImportError:
import DHParser.shadow_cython as cython
__all__ = ('StringView', 'real_indices', 'EMPTY_STRING_VIEW')
__all__ = ('StringView', 'real_indices', 'EMPTY_STRING_VIEW', 'TextBuffer')
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment