diff --git a/aider/repomap.py b/aider/repomap.py index 05fd5849d..4f00ebeb8 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -262,13 +262,15 @@ class RepoMap: res = [token[2] for token in tokens if token[1] in Token.Name] return res - def get_ranked_tags(self, fnames): + def get_ranked_tags(self, chat_fnames, other_fnames): defines = defaultdict(set) references = defaultdict(list) definitions = defaultdict(set) personalization = dict() + fnames = chat_fnames + other_fnames + show_fnames = set() for fname in sorted(fnames): dump(fname) @@ -345,26 +347,28 @@ class RepoMap: ident = data["ident"] ranked_definitions[(dst, ident)] += data["rank"] - clusters = dict() - for fname in set(show_fnames): - clusters[fname] = graphviz.Digraph(f"cluster_{fname}") - clusters[fname].attr(label=fname, style="filled") - clusters[fname].node(f"invis_{fname}", style="invis", width="0", label="") + draw_graph = False + + if draw_graph: + clusters = dict() + for fname in set(show_fnames): + clusters[fname] = graphviz.Digraph(f"cluster_{fname}") + clusters[fname].attr(label=fname, style="filled") + clusters[fname].node(f"invis_{fname}", style="invis", width="0", label="") ranked_tags = [] ranked_definitions = sorted(ranked_definitions.items(), reverse=True, key=lambda x: x[1]) for (fname, ident), rank in ranked_definitions: print(f"{rank:.03f} {fname} {ident}") - sz = str(rank * 25) - font_sz = rank * 500 - font_sz = str(max(10, font_sz)) - clusters[fname].node( - str((fname, ident)), label=ident, width=sz, height=sz, fontsize=font_sz - ) - ranked_tags += list(definitions.get((fname, ident), [])) - draw_graph = False + if draw_graph: + sz = str(rank * 25) + font_sz = rank * 500 + font_sz = str(max(10, font_sz)) + clusters[fname].node( + str((fname, ident)), label=ident, width=sz, height=sz, fontsize=font_sz + ) if draw_graph: dot = graphviz.Digraph(graph_attr={"ratio": ".5"}) @@ -387,8 +391,11 @@ class RepoMap: return ranked_tags - def get_ranked_tags_map(self, _chat_files, fnames): - ranked_tags = self.get_ranked_tags(fnames) + def get_ranked_tags_map(self, chat_fnames, other_fnames=None): + if not other_fnames: + other_fnames = list() + + ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames) num_tags = len(ranked_tags) lower_bound = 0