Add a "Debug ItemTree" LSP request

This commit is contained in:
Jonas Schievink
2021-05-21 23:59:52 +02:00
parent 8d13864440
commit 271ec6b990
9 changed files with 108 additions and 0 deletions

View File

@@ -117,6 +117,16 @@ pub(crate) fn handle_view_hir(
Ok(res)
}
pub(crate) fn handle_view_item_tree(
snap: GlobalStateSnapshot,
params: lsp_ext::ViewItemTreeParams,
) -> Result<String> {
let _p = profile::span("handle_view_item_tree");
let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
let res = snap.analysis.view_item_tree(file_id)?;
Ok(res)
}
pub(crate) fn handle_view_crate_graph(snap: GlobalStateSnapshot, (): ()) -> Result<String> {
let _p = profile::span("handle_view_crate_graph");
let dot = snap.analysis.view_crate_graph()??;

View File

@@ -70,6 +70,20 @@ impl Request for ViewCrateGraph {
const METHOD: &'static str = "rust-analyzer/viewCrateGraph";
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ViewItemTreeParams {
pub text_document: TextDocumentIdentifier,
}
pub enum ViewItemTree {}
impl Request for ViewItemTree {
type Params = ViewItemTreeParams;
type Result = String;
const METHOD: &'static str = "rust-analyzer/viewItemTree";
}
pub enum ExpandMacro {}
impl Request for ExpandMacro {

View File

@@ -514,6 +514,7 @@ impl GlobalState {
.on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)
.on::<lsp_ext::ViewHir>(handlers::handle_view_hir)
.on::<lsp_ext::ViewCrateGraph>(handlers::handle_view_crate_graph)
.on::<lsp_ext::ViewItemTree>(handlers::handle_view_item_tree)
.on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)
.on::<lsp_ext::ParentModule>(handlers::handle_parent_module)
.on::<lsp_ext::Runnables>(handlers::handle_runnables)