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:
Ville Penttinen 2019-03-03 12:02:55 +02:00
parent 17aaece6b3
commit ac52d9a1f1
4 changed files with 148 additions and 5 deletions

View file

@ -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)
}

View file

@ -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 {}