Stream: t-compiler/rust-analyzer

Topic: "End-user API" and listing symbols


Alessandro Re (Jan 16 2021 at 19:44, on Zulip):

Hello, I would like to perform some analysis over a rust workspace and I'm looking at RA for helping me in that.
To make it concrete, right now I would like to extract a list of all the external symbols used inside a crate. For example, all the symbols in std::, whether they are in use declarations or just used anywhere in the crate's code.

I started using R-A as a LSP server (which I'm not very familiar with): I successfully managed to start the process and query it via stdio, and using textDocument/documentSymbol I managet to get the symbols in the crate... But these are not including use declarations. It seems only crate-defined symbols are listed. Is there a better request for LSP towards this end, maybe?

As an alternative, I saw that R-A has some "end-user" ide API, and other crates that maybe I could use. I couldn't find many details on those, and even if I delved a bit into rustc and I can understand a few things, I'm not very familiar with IDE and compiler development and I'm not sure on how to start.

What could be a good point where to start?
Thank you!

matklad (Jan 18 2021 at 14:39, on Zulip):

Sadly, there are no good starting points yet -- providing an API is not the current goal of the project. (

Two places to look at would be crates/ide/src/lib.rs and crates/hir/src/code_model.rs

Alessandro Re (Jan 19 2021 at 21:56, on Zulip):

A starting point is good, and two are even better :) It's enough to start, thank you for taking some time to answer!

Last update: Jul 26 2021 at 14:30UTC