Extract all functions of a java file and make a dependency graph using kythe

129 views
Skip to first unread message

Jagannath Nalla

unread,
Jul 24, 2024, 2:33:13 PM7/24/24
to Kythe

Hey everyone, I'm new to Kythe and looking to use it for a specific task. I want to extract all functions within a class, maybe filter them based on their arguments, and then generate a dependency graph showing which other functions (potentially in different files) depend on them.

Is this something Kythe can handle? What are my options here? Are there any potential challenges I should be aware of?

Any help or guidance would be greatly appreciated!


michael.j....@gmail.com

unread,
Jul 26, 2024, 5:30:27 PM7/26/24
to Kythe
Broadly yes, this is exactly the kind of query Kythe is meant to handle. You'd need to index not just the package that defines the class, but also any other packages that you want cross-references for. The indexer generates nodes for each class, variable, method, etc. definition it finds, and edges from each referring expression (e.g., a variable usage or function call) to the object it references.

The general workflow is that you'll run the extractor and indexer for each package you care about, then combine the results together into a graph (e.g., using the write_tables tool), and that graph can then be served by http_server.

Unfortunately a lot of this is still pretty manual, and I haven't kept up with things over the past few years so some of the examples may have bit-rotted a bit. That said—the examples should be a decent starting point.

It is also worth noting that Google appears to have de-staffed the project, so it may be a bit of trial-and-error to get things going. :/

–M

Robin Palotai

unread,
Jul 27, 2024, 5:06:40 AM7/27/24
to michael.j....@gmail.com, Kythe

I'm not active in this space recently, but last time https://javaparser.org/ looked like a decent library.

BR,
Robin


--
You received this message because you are subscribed to the Google Groups "Kythe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/caba26f4-8e93-4b6d-a8b1-1bfb0e5d3afbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages