mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Add "view file text" command to debug sync issues
This commit is contained in:
parent
259182b50b
commit
ec2d023383
8 changed files with 89 additions and 1 deletions
|
@ -123,6 +123,14 @@ pub(crate) fn handle_view_hir(
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
pub(crate) fn handle_view_file_text(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::TextDocumentIdentifier,
|
||||
) -> Result<String> {
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.uri)?;
|
||||
Ok(snap.analysis.file_text(file_id)?.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn handle_view_item_tree(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::ViewItemTreeParams,
|
||||
|
|
|
@ -70,6 +70,14 @@ impl Request for ViewHir {
|
|||
const METHOD: &'static str = "rust-analyzer/viewHir";
|
||||
}
|
||||
|
||||
pub enum ViewFileText {}
|
||||
|
||||
impl Request for ViewFileText {
|
||||
type Params = lsp_types::TextDocumentIdentifier;
|
||||
type Result = String;
|
||||
const METHOD: &'static str = "rust-analyzer/viewFileText";
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ViewCrateGraphParams {
|
||||
|
|
|
@ -590,6 +590,7 @@ impl GlobalState {
|
|||
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)
|
||||
.on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)
|
||||
.on::<lsp_ext::ViewHir>(handlers::handle_view_hir)
|
||||
.on::<lsp_ext::ViewFileText>(handlers::handle_view_file_text)
|
||||
.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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue