The name of the initial branch for new projects is now "main" instead of "master". Existing projects remain unchanged. More information:

Commit 5c48da22 authored by di68kap's avatar di68kap
Browse files

- language server started

parent c29315c8
...@@ -342,6 +342,12 @@ class Server: ...@@ -342,6 +342,12 @@ class Server:
params = obj['params'] if 'params' in obj else () params = obj['params'] if 'params' in obj else ()
await run(method_name, method, params) await run(method_name, method, params)
error = cast(Dict[str, str], result['error'])
rpc_error = error['code'], error['message']
except TypeError:
pass # result is not a dictionary, never mind
if rpc_error is None: if rpc_error is None:
json_result = {"jsonrpc": "2.0", "result": result, "id": json_id} json_result = {"jsonrpc": "2.0", "result": result, "id": json_id}
writer.write(json.dumps(json_result, cls=DHParser_JSONEncoder).encode()) writer.write(json.dumps(json_result, cls=DHParser_JSONEncoder).encode())
...@@ -456,3 +462,34 @@ class Server: ...@@ -456,3 +462,34 @@ class Server:
while self.server_messages.get() != SERVER_OFFLINE: while self.server_messages.get() != SERVER_OFFLINE:
pass pass
self.terminate_server() self.terminate_server()
class LanguageServer(Server):
"""Template for the implementation of a language server.
cpu_bound = ALL_RPCs # type: Set[str]
blocking = frozenset() # type: Set[str]
def __init__(self):
rpc_table = dict() # type: RPC_Table
for attr in dir(self):
if attr.startswith('rpc_'):
name = attr[4:].replace('_', '/')
func = getattr(self, attr)
rpc_table[name] = func
super().__init__(rpc_table, self.cpu_bound, self.blocking)
self._initialized = False
def rpc_initialize(self,
processId: Optional[int],
rootPath: Optional[str],
rootUri: Optional[str],
initializeOptions: JSON_Type,
capabilities: JSON_Type,
trace: str,
workspaceFolders: List[Dict[str, str]]):
if self._initialized:
# Error Code -32002
\ No newline at end of file
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