Yes, something like TreeSitter would seem to be of more value - able to lookup symbols by name, and find the spans of source code where they are defined and used.
https://github.com/ast-grep/ast-grep
https://github.com/ast-grep/ast-grep