def on_query_completions(self, view, prefix, locations): # helpers.log_info("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) # if (not helpers.is_a_gold_view(view)) or (len(prefix) < 4): # return [] # api = environment.getSwaggerAPI() # fullChoiceList = api.MMBrowserAPI.MMBrowserAPI_searchEntities(q=prefix).result() # result = [] # for item in fullChoiceList: # result.append((item['label'], item['label'])) # print(result) # helpers.log_info("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) # return result helpers.log_info("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) if not helpers.is_a_gold_view(view): return [] moduleName = helpers.get_module_from_view(view) sourceCode = helpers.get_view_content(view).replace('\n', "\\r\\n") api = environment.getSwaggerAPI() tSuggestBody = api.get_model("tSuggestBody") tImplem = api.get_model("tImplem") rowcol = view.rowcol(locations[0]) lineRegion = view.line(locations[0]) lineContent = view.substr(lineRegion) lineInfo = { "lineContent": lineContent, "lineNumber": rowcol[0]+1, "ColumnNumber": rowcol[1]+1 } implem = { "name": moduleName, "ancestor": "", "content": sourceCode } suggestBody = tSuggestBody(implem=implem, lineInfo=lineInfo) fullChoiceList = api.ModuleDefAPI.ModuleDefAPI_Suggest(name=moduleName, body=suggestBody).result() result = [] for item in fullChoiceList["items"]: if item['insertText'] == "": result.append((item["label"], item["label"])) else: result.append((item["label"], item["insertText"])) helpers.log_info("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) if result == []: flag = 0 else: flag = sublime.INHIBIT_WORD_COMPLETIONS return (result, flag)
def update_readonly(view=None): if view == None: view = sublime.active_window().active_view() if not helpers.is_a_gold_view(view): return module_name = helpers.get_module_from_view(view) api = environment.getSwaggerAPI() status = api.ModuleDefAPI.ModuleDefAPI_entityStatus(name=module_name).result() view.set_read_only(not status['checkedOut'])
def on_modified_async(self, view): helpers.log_info("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) return now = time.time() if self.view_to_parse == None and helpers.is_a_gold_view(self.view_to_parse): self.view_to_parse = view name = helpers.get_module_from_view(self.view_to_parse) if helpers.is_entity_checkedout(name): sublime.set_timeout_async(self.treat_parses, 5000) helpers.log_info("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name) return None
def is_visible(self): return helpers.is_a_gold_view(self.view)
def is_enabled(self): return helpers.is_a_gold_view(self.view)
def is_visible(self): return helpers.is_a_gold_view(sublime.active_window().active_view())