diff options
author | Jean Pierre <jeanp413@hotmail.com> | 2021-03-23 18:33:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 10:33:25 +1100 |
commit | 77cfadf5321df90ea5fd625e2eb9d51b3920b437 (patch) | |
tree | 3bb56c344fd7cf5edc1516b78673ae1f35209d1e /cli/lsp/tsc.rs | |
parent | b233985feacb6a869e491e28474faa936dc07538 (diff) |
feat(lsp): implement textDocument/selectionRange (#9845)
Ref: #8643
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index a60f15eb8..c2418d157 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -1312,6 +1312,31 @@ impl SignatureHelpParameter { } #[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct SelectionRange { + text_span: TextSpan, + #[serde(skip_serializing_if = "Option::is_none")] + parent: Option<Box<SelectionRange>>, +} + +impl SelectionRange { + pub fn to_selection_range( + &self, + line_index: &LineIndex, + ) -> lsp::SelectionRange { + lsp::SelectionRange { + range: self.text_span.to_range(line_index), + parent: match &self.parent { + Some(parent_selection) => { + Some(Box::new(parent_selection.to_selection_range(line_index))) + } + None => None, + }, + } + } +} + +#[derive(Debug, Clone, Deserialize)] struct Response { id: usize, data: Value, @@ -1856,6 +1881,8 @@ pub enum RequestMethod { GetReferences((ModuleSpecifier, u32)), /// Get signature help items for a specific position. GetSignatureHelpItems((ModuleSpecifier, u32, SignatureHelpItemsOptions)), + /// Get a selection range for a specific position. + GetSmartSelectionRange((ModuleSpecifier, u32)), /// Get the diagnostic codes that support some form of code fix. GetSupportedCodeFixes, } @@ -1977,6 +2004,14 @@ impl RequestMethod { "options": options, }) } + RequestMethod::GetSmartSelectionRange((specifier, position)) => { + json!({ + "id": id, + "method": "getSmartSelectionRange", + "specifier": specifier, + "position": position + }) + } RequestMethod::GetSupportedCodeFixes => json!({ "id": id, "method": "getSupportedCodeFixes", |