mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
refac
This commit is contained in:
parent
360335f624
commit
36f21fcfb6
1 changed files with 23 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue