mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +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]
|
res = [token[2] for token in tokens if token[1] in Token.Name]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_ranked_tags(self, fnames):
|
def get_ranked_tags(self, chat_fnames, other_fnames):
|
||||||
defines = defaultdict(set)
|
defines = defaultdict(set)
|
||||||
references = defaultdict(list)
|
references = defaultdict(list)
|
||||||
definitions = defaultdict(set)
|
definitions = defaultdict(set)
|
||||||
|
|
||||||
personalization = dict()
|
personalization = dict()
|
||||||
|
|
||||||
|
fnames = chat_fnames + other_fnames
|
||||||
|
|
||||||
show_fnames = set()
|
show_fnames = set()
|
||||||
for fname in sorted(fnames):
|
for fname in sorted(fnames):
|
||||||
dump(fname)
|
dump(fname)
|
||||||
|
@ -345,26 +347,28 @@ class RepoMap:
|
||||||
ident = data["ident"]
|
ident = data["ident"]
|
||||||
ranked_definitions[(dst, ident)] += data["rank"]
|
ranked_definitions[(dst, ident)] += data["rank"]
|
||||||
|
|
||||||
clusters = dict()
|
draw_graph = False
|
||||||
for fname in set(show_fnames):
|
|
||||||
clusters[fname] = graphviz.Digraph(f"cluster_{fname}")
|
if draw_graph:
|
||||||
clusters[fname].attr(label=fname, style="filled")
|
clusters = dict()
|
||||||
clusters[fname].node(f"invis_{fname}", style="invis", width="0", label="")
|
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_tags = []
|
||||||
ranked_definitions = sorted(ranked_definitions.items(), reverse=True, key=lambda x: x[1])
|
ranked_definitions = sorted(ranked_definitions.items(), reverse=True, key=lambda x: x[1])
|
||||||
for (fname, ident), rank in ranked_definitions:
|
for (fname, ident), rank in ranked_definitions:
|
||||||
print(f"{rank:.03f} {fname} {ident}")
|
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), []))
|
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:
|
if draw_graph:
|
||||||
dot = graphviz.Digraph(graph_attr={"ratio": ".5"})
|
dot = graphviz.Digraph(graph_attr={"ratio": ".5"})
|
||||||
|
@ -387,8 +391,11 @@ class RepoMap:
|
||||||
|
|
||||||
return ranked_tags
|
return ranked_tags
|
||||||
|
|
||||||
def get_ranked_tags_map(self, _chat_files, fnames):
|
def get_ranked_tags_map(self, chat_fnames, other_fnames=None):
|
||||||
ranked_tags = self.get_ranked_tags(fnames)
|
if not other_fnames:
|
||||||
|
other_fnames = list()
|
||||||
|
|
||||||
|
ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames)
|
||||||
num_tags = len(ranked_tags)
|
num_tags = len(ranked_tags)
|
||||||
|
|
||||||
lower_bound = 0
|
lower_bound = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue