summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs35
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",