mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Add recursive expand in vscode
This commit is contained in:
parent
d2782ab1c1
commit
3ccd05fedc
8 changed files with 210 additions and 5 deletions
|
@ -436,6 +436,7 @@ fn on_request(
|
|||
})?
|
||||
.on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)?
|
||||
.on::<req::SyntaxTree>(handlers::handle_syntax_tree)?
|
||||
.on::<req::ExpandMacro>(handlers::handle_expand_macro)?
|
||||
.on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)?
|
||||
.on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)?
|
||||
.on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)?
|
||||
|
|
|
@ -47,6 +47,21 @@ pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn handle_expand_macro(
|
||||
world: WorldSnapshot,
|
||||
params: req::ExpandMacroParams,
|
||||
) -> Result<Option<(String, String)>> {
|
||||
let _p = profile("handle_expand_macro");
|
||||
let file_id = params.text_document.try_conv_with(&world)?;
|
||||
let line_index = world.analysis().file_line_index(file_id)?;
|
||||
let offset = params.position.map(|p| p.conv_with(&line_index));
|
||||
|
||||
match offset {
|
||||
None => Ok(None),
|
||||
Some(offset) => Ok(world.analysis().expand_macro(FilePosition { file_id, offset })?),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_selection_range(
|
||||
world: WorldSnapshot,
|
||||
params: req::SelectionRangeParams,
|
||||
|
|
|
@ -45,6 +45,21 @@ pub struct SyntaxTreeParams {
|
|||
pub range: Option<Range>,
|
||||
}
|
||||
|
||||
pub enum ExpandMacro {}
|
||||
|
||||
impl Request for ExpandMacro {
|
||||
type Params = ExpandMacroParams;
|
||||
type Result = Option<(String, String)>;
|
||||
const METHOD: &'static str = "rust-analyzer/expandMacro";
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExpandMacroParams {
|
||||
pub text_document: TextDocumentIdentifier,
|
||||
pub position: Option<Position>,
|
||||
}
|
||||
|
||||
pub enum SelectionRangeRequest {}
|
||||
|
||||
impl Request for SelectionRangeRequest {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue