示例#1
0
 def get_tags():
     loaded = TagFile(tags_file, FILENAME)
     if lang:
         return loaded.get_tags_dict_by_suffix(
             suffix, filters=compile_filters(view))
     else:
         return loaded.get_tags_dict(*files,
                                     filters=compile_filters(view))
示例#2
0
    def run(symbol, region, sym_line, mbrParts, view, tags_file):
        # print('JumpToDefinition')

        tags = {}
        for tags_file in get_alternate_tags_paths(view, tags_file):
            with TagFile(tags_file, SYMBOL) as tagfile:
                tags = tagfile.get_tags_dict(symbol,
                                             filters=compile_filters(view))
            if tags:
                break

        if not tags:
            return status_message('Can\'t find "%s"' % symbol)

        rankmgr = RankMgr(region, mbrParts, view, symbol, sym_line)

        @prepare_for_quickpanel()
        def sorted_tags():
            taglist = tags.get(symbol, [])
            p_tags = rankmgr.sort_tags(taglist)
            if not p_tags:
                status_message('Can\'t find "%s"' % symbol)
            return p_tags

        return sorted_tags
示例#3
0
    def run(symbol, view, tags_file):
        tags = {}
        for tags_file in alternate_tags_paths(view, tags_file):
            tags = (TagFile( tags_file, SYMBOL)
                            .get_tags_dict( symbol,
                                            filters=compile_filters(view)) )
            if tags: break

        if not tags:
            return status_message('Can\'t find "%s"' % symbol)

        current_file = view.file_name().replace(dirname(tags_file) + os.sep, '')

        def_filters = compile_definition_filters(view)
        def pass_def_filter(o):
            for f in def_filters:
                for k, v in list(f.items()):
                    if k in o:
                        if re.match(v, o[k]):
                            return False
            return True

        @prepared_4_quickpanel()
        def sorted_tags():
            p_tags = list(filter(pass_def_filter, tags.get(symbol, [])))
            if not p_tags:
                status_message('Can\'t find "%s"' % symbol)
            p_tags = sorted(p_tags, key=iget('tag_path'))
            return p_tags

        return sorted_tags
示例#4
0
    def run(symbol, view, tags_file):
        tags = {}
        for tags_file in get_alternate_tags_paths(view, tags_file):
            with TagFile(tags_file, SYMBOL) as tagfile:
                tags = tagfile.get_tags_dict(symbol,
                                             filters=compile_filters(view))
            if tags:
                break

        if not tags:
            return status_message('Can\'t find "%s"' % symbol)

        def_filters = compile_definition_filters(view)

        def pass_def_filter(o):
            for f in def_filters:
                for k, v in list(f.items()):
                    if k in o:
                        if re.match(v, o[k]):
                            return False
            return True

        @prepare_for_quickpanel()
        def sorted_tags():
            p_tags = list(filter(pass_def_filter, tags.get(symbol, [])))
            if not p_tags:
                status_message('Can\'t find "%s"' % symbol)
            p_tags = sorted(p_tags, key=iget('tag_path'))
            return p_tags

        return sorted_tags
示例#5
0
    def run(self, view, args, tags_file, tags):
        if not tags_file: return
        multi = args.get('type') == 'multi'

        files = files_to_search(view, tags_file, multi)
        if not files: return

        tags_file = tags_file + '_sorted_by_file'
        tags = (TagFile(tags_file,
                        FILENAME).get_tags_dict(*files,
                                                filters=compile_filters(view)))
        if not tags:
            if multi:
                view.run_command('show_symbols', {'type': 'multi'})
            else:
                sublime.status_message(
                    'No symbols found **FOR CURRENT FILE**; Try Rebuild?')

        path_cols = (0, ) if len(files) > 1 else ()
        formatting = functools.partial(format_tag_for_quickopen,
                                       file=bool(path_cols))

        @prepared_4_quickpanel(formatting, path_cols=())
        def sorted_tags():
            return sorted(chain(*(tags[k] for k in tags)),
                          key=iget('tag_path'))

        return sorted_tags
示例#6
0
 def get_tags():
     with TagFile(tags_file, FILENAME) as tagfile:
         if lang:
             return tagfile.get_tags_dict_by_suffix(
                 suffix, filters=compile_filters(view))
         elif multi:
             return tagfile.get_tags_dict(filters=compile_filters(view))
         else:
             return tagfile.get_tags_dict(*files,
                                          filters=compile_filters(view))
示例#7
0
 def on_query_completions(self, view, prefix, locations):
     if setting('autocomplete'):
         tags_path = find_tags_relative_to(view.file_name())
         if not tags_path or not os.path.exists(tags_path):  # check if a project is open and the .tags file exists
             return []
         results = []
         if sublime.platform() == 'windows':
             # Windows is lack of `grep' and `awk'
             tag_file = TagFile(tags_path, SYMBOL, MATCHES_STARTWITH)
             results = [(a, a) for a in tag_file.get_tags_dict(prefix[0])]
         else:
             # grep tags from project directory .tags file
             f = os.popen("grep -i '^%s' '%s' | awk '{ print $1 }'" % (prefix, tags_path))
             for i in f.readlines():
                 s = i.strip()
                 results.append((s, s))
         results = list(set(results))  # make unique
         results.sort()  # sort
         return results
示例#8
0
    def run(self, view, args, tags_file, tags):
        symbol = view.substr(view.word(view.sel()[0]))

        for tags_file in alternate_tags_paths(view, tags_file):
            tags = (TagFile(tags_file, SYMBOL).get_tags_dict(
                symbol, filters=compile_filters(view)))
            if tags: break

        if not tags:
            return status_message('Can\'t find "%s"' % symbol)

        current_file = view.file_name().replace(
            dirname(tags_file) + os.sep, '')

        def definition_cmp(a, b):
            if normpath(a.tag_path[0]) == current_file:
                return -1
            if normpath(b.tag_path[0]) == current_file:
                return 1
            return 0

        def_filters = compile_definition_filters(view)

        def pass_def_filter(o):
            for f in def_filters:
                for k, v in f.items():
                    if re.match(v, o[k]):
                        return False
            return True

        @prepared_4_quickpanel()
        def sorted_tags():
            p_tags = filter(pass_def_filter, tags.get(symbol, []))
            if not p_tags:
                status_message('Can\'t find "%s"' % symbol)
            p_tags = sorted(p_tags, key=iget('tag_path'))
            if setting('definition_current_first', False):
                p_tags = sorted(p_tags, cmp=definition_cmp)
            return p_tags

        return sorted_tags
示例#9
0
 def get_tags():
     loaded = TagFile(tags_file, FILENAME)
     if lang: return loaded.get_tags_dict_by_suffix(suffix, filters=compile_filters(view))
     else: return loaded.get_tags_dict(*files, filters=compile_filters(view))