What's the right way to think about linkifying a file?

59 views
Skip to first unread message

Theodore Dokos

unread,
Dec 27, 2022, 8:07:10 PM12/27/22
to Kythe
I'm trying to augment a code browser with clickable links, similar to how Codesearch works (for a c++ library, if that's important).

Naively, I can see two ways I could use Kythe to help me add links to the file I'm currently viewing:

1. Create the graph, then query for the graph node corresponding to the file I'm looking at. I can then find all child nodes of the file node, and start introspecting on each of those. The included http_server can't do this out of the box, correct? Once you have the child nodes you can run CrossReference rpcs, but it doesn't look like the existing APIs are meant to retrieve a file node and its children.

2. Use a separate system to parse the file, then extract symbols from the AST and run xref requests (like in the example http_server) against those symbols (after somehow figuring out the correct ticket for each symbol).

I came in thinking that #1 must be the way to go, but I've been having difficulty understanding how file nodes fit into the graph. When I run the entrystream tool, I see entries for files that lack a signature:

{ "source":{"corpus":"mycorpus", "path":"main.cpp"}, "fact_name":"/kythe/node/kind", "fact_value":"ZmlsZQ=="}

This confuses me. How can I refer to files in the graph edges if they don't have a signature?

Jonathan Godbout

unread,
Dec 27, 2022, 8:52:42 PM12/27/22
to Kythe
This is in fact the correct schema for a file, see:

Note "signature" isn't necessarily needed,
looking at the xref proto:
xref proto (which I imagine the service has to be using) https://github.com/kythe/kythe/blob/master/kythe/proto/xref.proto

you want:
```
rpc CrossReferences(CrossReferencesRequest) returns (CrossReferencesReply) {}
```

```
CrossReferencesRequest
```
takes a repeated string field of `ticket`


So: 
seems valid.

Note: I only use this internally, and on lisp, and it's been a few years.

Jay Sachs

unread,
Jan 2, 2023, 9:45:15 AM1/2/23
to Jonathan Godbout, Kythe
Navigating the graph requires being able to "spell" the VName for some nodes in the graph. In general, these "spellable" nodes will be the file nodes, which must not have a signature. But files themselves don't generally have terribly interesting links to other nodes. Typical usage is to request decorations for a file, specifying the spellable ticket (vname) for that file. From there, you can expand "outward" in the graph via the CrossReferences call using (one or more of) the ticket(s0 provided in the Decorations response, presumably selected by the user via some UI interaction.

--
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/bc3fd51f-2633-475d-8cd8-4571aa895892n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages