Пример #1
0
    def run(self, edit, b_new_start_point=False, line_number=-1, filename=""):
        if USMain.is_unrealscript_file():
            # open the file at line line_number if specified (gets called after it was calculated by the main instance)
            if line_number != -1 and filename != "":
                self.open_file(filename, line_number, b_new_start_point)
                return

            # get selected word
            region_word = self.view.word(self.view.sel()[0])
            word = self.view.substr(region_word)

            # if no word is selected or the cursor is at the beginning of the line, return to last location
            global last_location, current_location
            row, col = self.view.rowcol(self.view.sel()[0].begin())

            if last_location is not None and (word.strip() == "" or col == 0):
                active_file = self.view.file_name()

                if current_location.lower() == active_file.lower():
                    window = sublime.active_window()
                    window.open_file(last_location, sublime.ENCODED_POSITION)
                    window.open_file(last_location, sublime.ENCODED_POSITION)
                    last_location = None
                    return

            # get line left of cursor
            line = self.view.substr(
                sublime.Region(
                    self.view.line(self.view.sel()[0]).begin(),
                    region_word.begin()))
            line = line.lstrip().lower()
            # print line

            # if the end of the line is a whitespace or a '(' (meaning it is a function argument)
            # empty left_line
            if line == "" or ' ' == line[-1] or '\t' == line[
                    -1] or '(' == line[-1]:
                left_line = ""
            else:
                # get relevant part of the line
                left_line = USMain.get_relevant_text(line)
                # print left_line

            # calculate where to go inside the main instance of my plug-in.
            # Then, call this command again with a filename and a line number.
            USMain.evt_m().go_to_definition(left_line, word, line,
                                            b_new_start_point)

        elif is_unreal_log_file():  # self.view.file_name()
            line = self.view.substr(self.view.line(self.view.sel()[0]))
            split_line = re.split(r"\(|\)", line)  # line.split("()")
            if len(split_line) > 1:
                self.open_file(split_line[0], split_line[1], True)
            else:
                self.view.set_status('UnrealScriptGotoDefinition',
                                     '"' + line + '" not found!')
    def run(self, edit, b_new_start_point=False, line_number=-1, filename=""):
        if USMain.is_unrealscript_file():
            # open the file at line line_number if specified (gets called after it was calculated by the main instance)
            if line_number != -1 and filename != "":
                self.open_file(filename, line_number, b_new_start_point)
                return

            # get selected word
            region_word = self.view.word(self.view.sel()[0])
            word = self.view.substr(region_word)

            # if no word is selected or the cursor is at the beginning of the line, return to last location
            global last_location, current_location
            row, col = self.view.rowcol(self.view.sel()[0].begin())

            if last_location is not None and (word.strip() == "" or col == 0):
                active_file = self.view.file_name()

                if current_location.lower() == active_file.lower():
                    window = sublime.active_window()
                    window.open_file(last_location, sublime.ENCODED_POSITION)
                    window.open_file(last_location, sublime.ENCODED_POSITION)
                    last_location = None
                    return

            # get line left of cursor
            line = self.view.substr(sublime.Region(self.view.line(self.view.sel()[0]).begin(), region_word.begin()))
            line = line.lstrip().lower()
            # print line

            # if the end of the line is a whitespace or a '(' (meaning it is a function argument)
            # empty left_line
            if line == "" or ' ' == line[-1] or '\t' == line[-1] or '(' == line[-1]:
                left_line = ""
            else:
                # get relevant part of the line
                left_line = USMain.get_relevant_text(line)
                # print left_line

            # calculate where to go inside the main instance of my plug-in.
            # Then, call this command again with a filename and a line number.
            USMain.evt_m().go_to_definition(left_line, word, line, b_new_start_point)

        elif is_unreal_log_file():  # self.view.file_name()
            line = self.view.substr(self.view.line(self.view.sel()[0]))
            split_line = re.split(r"\(|\)", line)   # line.split("()")
            if len(split_line) > 1:
                self.open_file(split_line[0], split_line[1], True)
            else:
                self.view.set_status('UnrealScriptGotoDefinition', '"' + line + '" not found!')