def notify_document_open(self, version: int, path: pathlib.Path, text: str) -> None: params = DidOpenTextDocumentParams( TextDocumentItem(to_uri(path), self.language, version, text)) notify = json_rpc.JsonRPCNotify("textDocument/didOpen", util.to_dict(params)) self.stream.send_notify(notify)
def notify_document_change(self, version: int, path: pathlib.Path, text: str) -> None: params = DidChangeTextDocumentParams( TextDocumentIdentifier(to_uri(path), version), [TextDocumentContentChangeEvent(text)], ) notify = json_rpc.JsonRPCNotify("textDocument/didChange", util.to_dict(params)) self.stream.send_notify(notify)
async def diagnostics(self, **kw): notify = json_rpc.JsonRPCNotify(PUBLISH_DIAGNOSTICS, kw) body = json.dumps(util.to_dict(notify)) self.f.write( f'Content-Length: {len(body)}\r\n\r\n{body}'.encode('utf-8'))
def send_notify(self, notify: json_rpc.JsonRPCNotify): d = util.to_dict(notify) request_json = json.dumps(d, indent=2) logger.debug('<--%s', request_json) request_bytes = request_json.encode('utf-8') self._send_body(request_bytes)
def send_request(self, request: json_rpc.JsonRPCRequest): d = util.to_dict(request) request_json = json.dumps(d, indent=2) logger.debug('<-%d%s', request.id, request_json) request_bytes = request_json.encode('utf-8') self._send_body(request_bytes)
def create_postion_params(path: pathlib.Path, line: int, col: int) -> dict: params = TextDocumentPositionParams(TextDocumentIdentifier(to_uri(path)), Position(line, col)) return util.to_dict(params)