Skip to content

Commit d5e8fa6

Browse files
bors[bot]matklad
andcommitted
Merge #1682
1682: Drop support for old extendSelection API r=matklad a=matklad Emacs now handles this via native LSP request emacs-lsp/lsp-mode@dc86bbb r? @flodiebold (Have not actually tried elisp code) Co-authored-by: Aleksey Kladov <[email protected]>
2 parents cce3158 + 13eddd7 commit d5e8fa6

File tree

4 files changed

+4
-73
lines changed

4 files changed

+4
-73
lines changed

crates/ra_lsp_server/src/main_loop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ fn on_request(
346346
})?
347347
.on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)?
348348
.on::<req::SyntaxTree>(handlers::handle_syntax_tree)?
349-
.on::<req::ExtendSelection>(handlers::handle_extend_selection)?
350349
.on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)?
351350
.on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)?
352351
.on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)?

crates/ra_lsp_server/src/main_loop/handlers.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use lsp_types::{
99
TextEdit, WorkspaceEdit,
1010
};
1111
use ra_ide_api::{
12-
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, Runnable, RunnableKind,
12+
AssistId, FileId, FilePosition, FileRange, FoldKind, Query, Runnable, RunnableKind,
1313
};
1414
use ra_prof::profile;
1515
use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
@@ -45,27 +45,6 @@ pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -
4545
Ok(res)
4646
}
4747

48-
// FIXME: drop this API
49-
pub fn handle_extend_selection(
50-
world: WorldSnapshot,
51-
params: req::ExtendSelectionParams,
52-
) -> Result<req::ExtendSelectionResult> {
53-
log::error!(
54-
"extend selection is deprecated and will be removed soon,
55-
use the new selection range API in LSP",
56-
);
57-
let file_id = params.text_document.try_conv_with(&world)?;
58-
let line_index = world.analysis().file_line_index(file_id)?;
59-
let selections = params
60-
.selections
61-
.into_iter()
62-
.map_conv_with(&line_index)
63-
.map(|range| FileRange { file_id, range })
64-
.map(|frange| world.analysis().extend_selection(frange).map(|it| it.conv_with(&line_index)))
65-
.collect::<Cancelable<Vec<_>>>()?;
66-
Ok(req::ExtendSelectionResult { selections })
67-
}
68-
6948
pub fn handle_selection_range(
7049
world: WorldSnapshot,
7150
params: req::SelectionRangeParams,

crates/ra_lsp_server/src/req.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,6 @@ pub struct SyntaxTreeParams {
4343
pub range: Option<Range>,
4444
}
4545

46-
pub enum ExtendSelection {}
47-
48-
impl Request for ExtendSelection {
49-
type Params = ExtendSelectionParams;
50-
type Result = ExtendSelectionResult;
51-
const METHOD: &'static str = "rust-analyzer/extendSelection";
52-
}
53-
54-
#[derive(Deserialize, Debug)]
55-
#[serde(rename_all = "camelCase")]
56-
pub struct ExtendSelectionParams {
57-
pub text_document: TextDocumentIdentifier,
58-
pub selections: Vec<Range>,
59-
}
60-
61-
#[derive(Serialize, Debug)]
62-
#[serde(rename_all = "camelCase")]
63-
pub struct ExtendSelectionResult {
64-
pub selections: Vec<Range>,
65-
}
66-
6746
pub enum SelectionRangeRequest {}
6847

6948
impl Request for SelectionRangeRequest {

editors/emacs/ra-emacs-lsp.el

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
;; - 'hover' type information & documentation (with lsp-ui)
1515
;; - implements source changes (for code actions etc.), except for file system changes
1616
;; - implements joinLines (you need to bind rust-analyzer-join-lines to a key)
17-
;; - implements extendSelection (either bind rust-analyzer-extend-selection to a key, or use expand-region)
17+
;; - implements selectionRanges (either bind lsp-extend-selection to a key, or use expand-region)
1818
;; - provides rust-analyzer-inlay-hints-mode for inline type hints
1919

2020
;; What's missing:
@@ -103,39 +103,13 @@
103103
(rust-analyzer--join-lines-params)))
104104
(rust-analyzer--apply-source-change)))
105105

106-
;; extend selection
107-
108-
(defun rust-analyzer-extend-selection ()
109-
(interactive)
110-
(-let (((&hash "start" "end") (rust-analyzer--extend-selection)))
111-
(rust-analyzer--goto-lsp-loc start)
112-
(set-mark (point))
113-
(rust-analyzer--goto-lsp-loc end)
114-
(exchange-point-and-mark)))
115-
116-
(defun rust-analyzer--extend-selection-params ()
117-
"Extend selection params."
118-
(list :textDocument (lsp--text-document-identifier)
119-
:selections
120-
(vector
121-
(if (use-region-p)
122-
(lsp--region-to-range (region-beginning) (region-end))
123-
(lsp--region-to-range (point) (point))))))
124-
125-
(defun rust-analyzer--extend-selection ()
126-
(->
127-
(lsp-send-request
128-
(lsp-make-request
129-
"rust-analyzer/extendSelection"
130-
(rust-analyzer--extend-selection-params)))
131-
(ht-get "selections")
132-
(seq-first)))
106+
;; selection ranges
133107

134108
(defun rust-analyzer--add-er-expansion ()
135109
(make-variable-buffer-local 'er/try-expand-list)
136110
(setq er/try-expand-list (append
137111
er/try-expand-list
138-
'(rust-analyzer-extend-selection))))
112+
'(lsp-extend-selection))))
139113

140114
(with-eval-after-load 'expand-region
141115
;; add the expansion for all existing rust-mode buffers. If expand-region is

0 commit comments

Comments
 (0)