예제 #1
0
    def on_query_completions(self, view, prefix, operand):
        completions = []
        name_of_source = None
        if not is_robot_language_file(view.file_name(),
                                      settings.associated_file_extensions):
            return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
            # ignore 'prefix' argument, instead get text under cursor using custom method
        text_under_cursor = get_text_under_cursor(view)
        if not text_under_cursor:
            return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
        result = re.split('\.', text_under_cursor, maxsplit=1)
        if len(result) == 2:
            name_of_source = result[0]
            text_under_cursor = result[1]
        completions = self.autocomplete_owner.get_autocomplete_list(
            text_under_cursor, name_of_source=name_of_source)
        completions_dynamic = self.autocomplete_dynamic_owner.get_autocomplete_list(
            text_under_cursor)
        completions.extend(completions_dynamic)

        # The event listeners works for every file in scope(for all opened .txt and .robot files)
        # in a separate thread, thus result may have duplicates.
        # Clean it.
        completions = list(set(completions))
        completions.sort()
        return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
    def on_query_completions(self, view, prefix, operand):
        completions = []
        name_of_source = None
        if not is_robot_language_file(view.file_name(), settings.associated_file_extensions):
            return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
            # ignore 'prefix' argument, instead get text under cursor using custom method
        text_under_cursor = get_text_under_cursor(view)
        if not text_under_cursor:
            return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
        result = re.split('\.', text_under_cursor, maxsplit=1)
        if len(result) == 2:
            name_of_source = result[0]
            text_under_cursor = result[1]
        completions = self.autocomplete_owner.get_autocomplete_list(text_under_cursor,
                                                                    name_of_source=name_of_source)
        completions_dynamic = self.autocomplete_dynamic_owner.get_autocomplete_list(
            text_under_cursor)
        completions.extend(completions_dynamic)

        # The event listeners works for every file in scope(for all opened .txt and .robot files)
        # in a separate thread, thus result may have duplicates.
        # Clean it.
        completions = list(set(completions))
        completions.sort()
        return completions, sublime.INHIBIT_EXPLICIT_COMPLETIONS
 def autodetect(self, view):
     view_file_name = view.file_name()
     if all([
             view_file_name is not None,
             is_robot_language_file(view_file_name,
                                    settings.associated_file_extensions),
             view.find(detect_robot_regex, 0, sublime.IGNORECASE)
             is not None
     ]):
         view.set_syntax_file(robot_tm_language_path)
 def autodetect(self, view):
     view_file_name = view.file_name()
     if all(
         [
             view_file_name is not None,
             is_robot_language_file(view_file_name, settings.associated_file_extensions),
             view.find(detect_robot_regex, 0, sublime.IGNORECASE) is not None,
         ]
     ):
         view.set_syntax_file(robot_tm_language_path)