mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
wip
This commit is contained in:
parent
f5e27cee8a
commit
a5f4cba72f
1 changed files with 21 additions and 18 deletions
|
@ -21,7 +21,7 @@ from aider.utils import Spinner
|
||||||
|
|
||||||
# tree_sitter is throwing a FutureWarning
|
# tree_sitter is throwing a FutureWarning
|
||||||
warnings.simplefilter("ignore", category=FutureWarning)
|
warnings.simplefilter("ignore", category=FutureWarning)
|
||||||
from tree_sitter_languages import get_language, get_parser # noqa: E402
|
from tree_sitter_language_pack import get_language, get_parser # noqa: E402
|
||||||
|
|
||||||
Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
|
Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
|
||||||
|
|
||||||
|
@ -216,28 +216,31 @@ class RepoMap:
|
||||||
query = language.query(query_scm)
|
query = language.query(query_scm)
|
||||||
captures = query.captures(tree.root_node)
|
captures = query.captures(tree.root_node)
|
||||||
|
|
||||||
captures = list(captures)
|
dump(fname)
|
||||||
|
dump(captures)
|
||||||
|
dump(captures.keys())
|
||||||
|
|
||||||
saw = set()
|
saw = set()
|
||||||
for node, tag in captures:
|
for tag, nodes in captures.items():
|
||||||
if tag.startswith("name.definition."):
|
for node in nodes:
|
||||||
kind = "def"
|
if tag.startswith("name.definition."):
|
||||||
elif tag.startswith("name.reference."):
|
kind = "def"
|
||||||
kind = "ref"
|
elif tag.startswith("name.reference."):
|
||||||
else:
|
kind = "ref"
|
||||||
continue
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
saw.add(kind)
|
saw.add(kind)
|
||||||
|
|
||||||
result = Tag(
|
result = Tag(
|
||||||
rel_fname=rel_fname,
|
rel_fname=rel_fname,
|
||||||
fname=fname,
|
fname=fname,
|
||||||
name=node.text.decode("utf-8"),
|
name=node.text.decode("utf-8"),
|
||||||
kind=kind,
|
kind=kind,
|
||||||
line=node.start_point[0],
|
line=node.start_point[0],
|
||||||
)
|
)
|
||||||
|
|
||||||
yield result
|
yield result
|
||||||
|
|
||||||
if "ref" in saw:
|
if "ref" in saw:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue