Doctave / dossier

A multi-language source code analyzer and docstrings parser
Mozilla Public License 2.0
52 stars 4 forks source link

Investigate using tree-sitter-stack-graphs for name resolution #10

Open begleynk opened 10 months ago

begleynk commented 10 months ago

I posted Dossier on the Rust subreddit, and user grunzl very helpfully pointed out that we could consider using https://github.com/github/stack-graphs and its tree-sitter integration for name resolution instead of rolling our own.

In short, stack graphs create a graph of symbols and their scopes, which you can then probe to resolve names to their definitions (aka "jump to definition"). You have to write a similar DSL to tree sitter queries to describe the rules for each language, and you can then use stack graphs to resolve names even across imports.

This is the technology that apparently powers GitHub's code navigation.

Definitely worth exploring, since relying on existing research/tooling in this area would be much preferred to rolling our own.

Boscop commented 1 month ago

Have you looked into tree-sitter-stack-graphs since then?

There are already crates for the languages typescript, python, javascript, ruby, java.