mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
improved debug main() func
This commit is contained in:
parent
fb5616f854
commit
4347823c36
2 changed files with 13 additions and 35 deletions
|
@ -1,23 +0,0 @@
|
||||||
(translation_unit
|
|
||||||
(function_definition
|
|
||||||
declarator: (function_declarator
|
|
||||||
declarator: (identifier) @name.definition.function
|
|
||||||
)
|
|
||||||
body: (compound_statement) @body.function
|
|
||||||
) @definition.function
|
|
||||||
|
|
||||||
(struct_specifier
|
|
||||||
name: (type_identifier) @name.definition.struct
|
|
||||||
body: (field_declaration_list) @body.struct
|
|
||||||
) @definition.struct
|
|
||||||
|
|
||||||
(union_specifier
|
|
||||||
name: (type_identifier) @name.definition.union
|
|
||||||
body: (field_declaration_list) @body.union
|
|
||||||
) @definition.union
|
|
||||||
|
|
||||||
(enum_specifier
|
|
||||||
name: (type_identifier) @name.definition.enum
|
|
||||||
body: (enumerator_list) @body.enum
|
|
||||||
) @definition.enum
|
|
||||||
)
|
|
|
@ -181,6 +181,8 @@ class RepoMap:
|
||||||
scm_fname = pkg_resources.resource_filename(
|
scm_fname = pkg_resources.resource_filename(
|
||||||
__name__, os.path.join("queries", f"tree-sitter-{lang}-tags.scm")
|
__name__, os.path.join("queries", f"tree-sitter-{lang}-tags.scm")
|
||||||
)
|
)
|
||||||
|
dump(fname)
|
||||||
|
dump(scm_fname)
|
||||||
query_scm = Path(scm_fname)
|
query_scm = Path(scm_fname)
|
||||||
if not query_scm.exists():
|
if not query_scm.exists():
|
||||||
return
|
return
|
||||||
|
@ -194,8 +196,10 @@ class RepoMap:
|
||||||
captures = query.captures(tree.root_node)
|
captures = query.captures(tree.root_node)
|
||||||
|
|
||||||
captures = list(captures)
|
captures = list(captures)
|
||||||
|
dump(captures)
|
||||||
|
|
||||||
for node, tag in captures:
|
for node, tag in captures:
|
||||||
|
dump(node, tag)
|
||||||
if tag.startswith("name.definition."):
|
if tag.startswith("name.definition."):
|
||||||
kind = "def"
|
kind = "def"
|
||||||
elif tag.startswith("name.reference."):
|
elif tag.startswith("name.reference."):
|
||||||
|
@ -343,16 +347,15 @@ class RepoMap:
|
||||||
return best_tree
|
return best_tree
|
||||||
|
|
||||||
|
|
||||||
def find_py_files(directory):
|
def find_src_files(directory):
|
||||||
if not os.path.isdir(directory):
|
if not os.path.isdir(directory):
|
||||||
return [directory]
|
return [directory]
|
||||||
|
|
||||||
py_files = []
|
src_files = []
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(".py"):
|
src_files.append(os.path.join(root, file))
|
||||||
py_files.append(os.path.join(root, file))
|
return src_files
|
||||||
return py_files
|
|
||||||
|
|
||||||
|
|
||||||
def get_random_color():
|
def get_random_color():
|
||||||
|
@ -367,15 +370,13 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
chat_fnames = []
|
chat_fnames = []
|
||||||
other_fnames = []
|
other_fnames = []
|
||||||
for dname in sys.argv[1:]:
|
for fname in sys.argv[1:]:
|
||||||
if ".venv" in dname:
|
if Path(fname).is_dir():
|
||||||
other_fnames += find_py_files(dname)
|
chat_fnames += find_src_files(fname)
|
||||||
else:
|
else:
|
||||||
chat_fnames += find_py_files(dname)
|
chat_fnames.append(fname)
|
||||||
|
|
||||||
root = os.path.commonpath(chat_fnames)
|
rm = RepoMap(root=".")
|
||||||
|
|
||||||
rm = RepoMap(root=root)
|
|
||||||
repo_map = rm.get_ranked_tags_map(chat_fnames, other_fnames)
|
repo_map = rm.get_ranked_tags_map(chat_fnames, other_fnames)
|
||||||
|
|
||||||
dump(len(repo_map))
|
dump(len(repo_map))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue