Add optional range parameter to SyntaxTreeParams
When range is provided, instead of showing the syntax for the whole file, we'll show the syntax tree for the given range.
This commit is contained in:
@@ -32,7 +32,9 @@ pub fn handle_analyzer_status(world: ServerWorld, _: ()) -> Result<String> {
|
||||
|
||||
pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> {
|
||||
let id = params.text_document.try_conv_with(&world)?;
|
||||
let res = world.analysis().syntax_tree(id);
|
||||
let line_index = world.analysis().file_line_index(id);
|
||||
let text_range = params.range.map(|p| p.conv_with(&line_index));
|
||||
let res = world.analysis().syntax_tree(id, text_range);
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ impl Request for SyntaxTree {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyntaxTreeParams {
|
||||
pub text_document: TextDocumentIdentifier,
|
||||
pub range: Option<Range>,
|
||||
}
|
||||
|
||||
pub enum ExtendSelection {}
|
||||
|
||||
Reference in New Issue
Block a user