Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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'))
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
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)