def completions(self, path, location=Location(1, 1), prefix="", onCompleted=None): req = servicedefs.CompletionsRequest(self.incrSeq(), servicedefs.CompletionsRequestArgs(path, location.line, location.col, prefix)) jsonStr = jsonhelpers.encode(req) def onCompletedJson(responseDict): obj = jsonhelpers.fromDict(servicedefs.CompletionsResponse, responseDict) onCompleted(obj) self.__comm.sendCmd(onCompletedJson, jsonStr, req.seq)
def quickInfo(self, path, location=Location(1, 1), onCompleted=None): req = servicedefs.QuickInfoRequest(self.incrSeq(), servicedefs.FileLocationRequestArgs(path, location.line, location.col)) jsonStr = jsonhelpers.encode(req) def onCompletedJson(json): obj = jsonhelpers.fromDict(servicedefs.QuickInfoResponse, json) if onCompleted: onCompleted(obj) self.__comm.sendCmd(onCompletedJson, jsonStr, req.seq)
def queue_signature_popup(self, view): cursor = view.rowcol(view.sel()[0].begin()) point = Location(cursor[0] + 1, cursor[1] + 1) filename = view.file_name() # Define a function to do the request and notify on completion def get_signature_data(on_done): self.proxy.asyncSignatureHelp(filename, point, '', on_done) # Schedule the request self.scheduler.queue_request(get_signature_data, lambda resp: self.on_response(resp, view))
def type(self, path, location=Location(1, 1)): req = servicedefs.TypeRequest(self.incrSeq(), servicedefs.FileLocationRequestArgs(path, location.line, location.col)) jsonStr = jsonhelpers.encode(req) responseDict = self.__comm.sendCmdSync(jsonStr, req.seq) return jsonhelpers.fromDict(servicedefs.TypeResponse, responseDict)
def formatOnKey(self, path, location=Location(1, 1), key=""): req = servicedefs.FormatOnKeyRequest(self.incrSeq(), servicedefs.FormatOnKeyRequestArgs(path, location.line, location.col, key)) jsonStr = jsonhelpers.encode(req) responseDict = self.__comm.sendCmdSync(jsonStr, req.seq) return jsonhelpers.fromDict(servicedefs.FormatResponse, responseDict)
def format(self, path, beginLoc=Location(1, 1), endLoc=Location(1, 1)): req = servicedefs.FormatRequest(self.incrSeq(), servicedefs.FormatRequestArgs(path, beginLoc.line, beginLoc.col, endLoc.line, endLoc.col)) jsonStr = jsonhelpers.encode(req) responseDict = self.__comm.sendCmdSync(jsonStr, req.seq) return jsonhelpers.fromDict(servicedefs.FormatResponse, responseDict)
def change(self, path, location=Location(1, 1), endLocation=Location(1,1), insertString=""): req = servicedefs.ChangeRequest(self.incrSeq(),servicedefs.ChangeRequestArgs(path, location.line, location.col, endLocation.line, endLocation.col, insertString)) jsonStr = jsonhelpers.encode(req) self.__comm.postCmd(jsonStr)