def run(self, paths=None): """ Run command - open search for definition window """ # check ctags is exists ctags_file = self.get_ctags_file(self.get_path(paths)) if ctags_file is None or not os.path.exists(ctags_file): return [] # check ctags is prepared - prepare if needed global ctags if ctags is None: ctags = CTags(tags_file=ctags_file, debug=is_debug) # get all definitions of selected word self._definitions = ctags.get_definitions() if not self._definitions: # return sublime.status_message("Can't find '%s'" % symbol) return # else show definitions list definitions = [[d[3][2:-4].strip(), "%d: %s" % (d[2], self.prettify_path(d[1]))] for d in self._definitions] self.window.show_quick_panel(definitions, self.select_definition)
def run(self, edit): """ Run command - jump to word under cursor definition """ # skip non-python files if not self.view.match_selector(0, "source.python"): return # check ctags is exists ctags_file = self.get_ctags_file(self.view.file_name()) if ctags_file is None or not os.path.exists(ctags_file): return [] # check ctags is prepared - prepare if needed global ctags if ctags is None: ctags = CTags(tags_file=ctags_file, debug=is_debug) # get word under cursor symbol = self.view.substr(self.view.word(self.view.sel()[0])) # get all definitions of selected word self._definitions = ctags.get_definitions(symbol) if not self._definitions: return sublime.status_message("Can't find '%s'" % symbol) # check settings instant_jump = settings.get("instant_jump_to_definition", False) if len(self._definitions) == 1 and instant_jump: # instant jump to definition if such setting and only one result self.select_definition(0) else: # else show definitions list definitions = [[d[3][2:-4].strip(), "%d: %s" % (d[2], self.prettify_path(d[1]))] for d in self._definitions] self.view.window().show_quick_panel(definitions, self.select_definition)