diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/caps.rs | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/document.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lsp_utils.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 18 | ||||
-rw-r--r-- | crates/rust-analyzer/tests/rust-analyzer/support.rs | 4 |
10 files changed, 26 insertions, 27 deletions
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index d25c4bf83..56c51486f 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -21,7 +21,7 @@ env_logger = { version = "0.8.1", default-features = false } | |||
21 | itertools = "0.9.0" | 21 | itertools = "0.9.0" |
22 | jod-thread = "0.1.0" | 22 | jod-thread = "0.1.0" |
23 | log = "0.4.8" | 23 | log = "0.4.8" |
24 | lsp-types = { version = "0.83.0", features = ["proposed"] } | 24 | lsp-types = { version = "0.83.1", features = ["proposed"] } |
25 | parking_lot = "0.11.0" | 25 | parking_lot = "0.11.0" |
26 | pico-args = "0.3.1" | 26 | pico-args = "0.3.1" |
27 | oorandom = "11.1.2" | 27 | oorandom = "11.1.2" |
@@ -31,7 +31,7 @@ serde_json = "1.0.48" | |||
31 | threadpool = "1.7.1" | 31 | threadpool = "1.7.1" |
32 | rayon = "1.5" | 32 | rayon = "1.5" |
33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | 33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } |
34 | lsp-server = "0.4.0" | 34 | lsp-server = "0.5.0" |
35 | tracing = "0.1" | 35 | tracing = "0.1" |
36 | tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } | 36 | tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } |
37 | tracing-tree = { version = "0.1.4" } | 37 | tracing-tree = { version = "0.1.4" } |
diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 9a8870053..c7203451c 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs | |||
@@ -62,6 +62,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti | |||
62 | prepare_provider: Some(true), | 62 | prepare_provider: Some(true), |
63 | work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, | 63 | work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, |
64 | })), | 64 | })), |
65 | on_type_rename_provider: None, | ||
65 | document_link_provider: None, | 66 | document_link_provider: None, |
66 | color_provider: None, | 67 | color_provider: None, |
67 | execute_command_provider: None, | 68 | execute_command_provider: None, |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 15145415b..93bef5c8b 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -55,8 +55,8 @@ fn location_naive(workspace_root: &Path, span: &DiagnosticSpan) -> lsp_types::Lo | |||
55 | 55 | ||
56 | // FIXME: this doesn't handle UTF16 offsets correctly | 56 | // FIXME: this doesn't handle UTF16 offsets correctly |
57 | let range = lsp_types::Range::new( | 57 | let range = lsp_types::Range::new( |
58 | lsp_types::Position::new(span.line_start as u64 - 1, span.column_start as u64 - 1), | 58 | lsp_types::Position::new(span.line_start as u32 - 1, span.column_start as u32 - 1), |
59 | lsp_types::Position::new(span.line_end as u64 - 1, span.column_end as u64 - 1), | 59 | lsp_types::Position::new(span.line_end as u32 - 1, span.column_end as u32 - 1), |
60 | ); | 60 | ); |
61 | 61 | ||
62 | lsp_types::Location { uri, range } | 62 | lsp_types::Location { uri, range } |
diff --git a/crates/rust-analyzer/src/document.rs b/crates/rust-analyzer/src/document.rs index 04c7ee150..cf091510f 100644 --- a/crates/rust-analyzer/src/document.rs +++ b/crates/rust-analyzer/src/document.rs | |||
@@ -6,11 +6,11 @@ | |||
6 | /// client notifications. | 6 | /// client notifications. |
7 | #[derive(Debug, Clone)] | 7 | #[derive(Debug, Clone)] |
8 | pub(crate) struct DocumentData { | 8 | pub(crate) struct DocumentData { |
9 | pub(crate) version: Option<i64>, | 9 | pub(crate) version: i32, |
10 | } | 10 | } |
11 | 11 | ||
12 | impl DocumentData { | 12 | impl DocumentData { |
13 | pub(crate) fn new(version: i64) -> Self { | 13 | pub(crate) fn new(version: i32) -> Self { |
14 | DocumentData { version: Some(version) } | 14 | DocumentData { version } |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 63c70a09d..defe11c55 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -263,9 +263,9 @@ impl GlobalStateSnapshot { | |||
263 | self.vfs.read().1[&id] | 263 | self.vfs.read().1[&id] |
264 | } | 264 | } |
265 | 265 | ||
266 | pub(crate) fn url_file_version(&self, url: &Url) -> Option<i64> { | 266 | pub(crate) fn url_file_version(&self, url: &Url) -> Option<i32> { |
267 | let path = from_proto::vfs_path(&url).ok()?; | 267 | let path = from_proto::vfs_path(&url).ok()?; |
268 | self.mem_docs.get(&path)?.version | 268 | Some(self.mem_docs.get(&path)?.version) |
269 | } | 269 | } |
270 | 270 | ||
271 | pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url { | 271 | pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url { |
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index a5c65fa3e..93ac45415 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs | |||
@@ -302,7 +302,7 @@ pub enum SnippetDocumentChangeOperation { | |||
302 | #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] | 302 | #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
303 | #[serde(rename_all = "camelCase")] | 303 | #[serde(rename_all = "camelCase")] |
304 | pub struct SnippetTextDocumentEdit { | 304 | pub struct SnippetTextDocumentEdit { |
305 | pub text_document: lsp_types::VersionedTextDocumentIdentifier, | 305 | pub text_document: lsp_types::OptionalVersionedTextDocumentIdentifier, |
306 | pub edits: Vec<SnippetTextEdit>, | 306 | pub edits: Vec<SnippetTextEdit>, |
307 | } | 307 | } |
308 | 308 | ||
diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index 1d271a9d8..6427c7367 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs | |||
@@ -51,7 +51,7 @@ impl GlobalState { | |||
51 | } | 51 | } |
52 | let percentage = fraction.map(|f| { | 52 | let percentage = fraction.map(|f| { |
53 | assert!(0.0 <= f && f <= 1.0); | 53 | assert!(0.0 <= f && f <= 1.0); |
54 | f * 100.0 | 54 | (f * 100.0) as u32 |
55 | }); | 55 | }); |
56 | let token = lsp_types::ProgressToken::String(format!("rustAnalyzer/{}", title)); | 56 | let token = lsp_types::ProgressToken::String(format!("rustAnalyzer/{}", title)); |
57 | let work_done_progress = match state { | 57 | let work_done_progress = match state { |
@@ -98,11 +98,11 @@ pub(crate) fn apply_document_changes( | |||
98 | // The VFS will normalize the end of lines to `\n`. | 98 | // The VFS will normalize the end of lines to `\n`. |
99 | enum IndexValid { | 99 | enum IndexValid { |
100 | All, | 100 | All, |
101 | UpToLineExclusive(u64), | 101 | UpToLineExclusive(u32), |
102 | } | 102 | } |
103 | 103 | ||
104 | impl IndexValid { | 104 | impl IndexValid { |
105 | fn covers(&self, line: u64) -> bool { | 105 | fn covers(&self, line: u32) -> bool { |
106 | match *self { | 106 | match *self { |
107 | IndexValid::UpToLineExclusive(to) => to > line, | 107 | IndexValid::UpToLineExclusive(to) => to > line, |
108 | _ => true, | 108 | _ => true, |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 68a53bbcb..6ea08adce 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -368,7 +368,7 @@ impl GlobalState { | |||
368 | let url = file_id_to_url(&self.vfs.read().0, file_id); | 368 | let url = file_id_to_url(&self.vfs.read().0, file_id); |
369 | let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect(); | 369 | let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect(); |
370 | let version = from_proto::vfs_path(&url) | 370 | let version = from_proto::vfs_path(&url) |
371 | .map(|path| self.mem_docs.get(&path)?.version) | 371 | .map(|path| self.mem_docs.get(&path).map(|it| it.version)) |
372 | .unwrap_or_default(); | 372 | .unwrap_or_default(); |
373 | 373 | ||
374 | self.send_notification::<lsp_types::notification::PublishDiagnostics>( | 374 | self.send_notification::<lsp_types::notification::PublishDiagnostics>( |
@@ -521,7 +521,7 @@ impl GlobalState { | |||
521 | let mut version = None; | 521 | let mut version = None; |
522 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { | 522 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { |
523 | match this.mem_docs.remove(&path) { | 523 | match this.mem_docs.remove(&path) { |
524 | Some(doc) => version = doc.version, | 524 | Some(doc) => version = Some(doc.version), |
525 | None => log::error!("orphan DidCloseTextDocument: {}", path), | 525 | None => log::error!("orphan DidCloseTextDocument: {}", path), |
526 | } | 526 | } |
527 | 527 | ||
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 4bdf4bf0f..2f35425bb 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -21,9 +21,7 @@ use crate::{ | |||
21 | 21 | ||
22 | pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position { | 22 | pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position { |
23 | let line_col = line_index.line_col(offset); | 23 | let line_col = line_index.line_col(offset); |
24 | let line = u64::from(line_col.line); | 24 | lsp_types::Position::new(line_col.line, line_col.col_utf16) |
25 | let character = u64::from(line_col.col_utf16); | ||
26 | lsp_types::Position::new(line, character) | ||
27 | } | 25 | } |
28 | 26 | ||
29 | pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Range { | 27 | pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Range { |
@@ -278,9 +276,9 @@ pub(crate) fn signature_help( | |||
278 | label.push_str(", "); | 276 | label.push_str(", "); |
279 | } | 277 | } |
280 | first = false; | 278 | first = false; |
281 | let start = label.len() as u64; | 279 | let start = label.len() as u32; |
282 | label.push_str(param); | 280 | label.push_str(param); |
283 | let end = label.len() as u64; | 281 | let end = label.len() as u32; |
284 | params.push(lsp_types::ParameterInformation { | 282 | params.push(lsp_types::ParameterInformation { |
285 | label: lsp_types::ParameterLabel::LabelOffsets([start, end]), | 283 | label: lsp_types::ParameterLabel::LabelOffsets([start, end]), |
286 | documentation: None, | 284 | documentation: None, |
@@ -302,7 +300,7 @@ pub(crate) fn signature_help( | |||
302 | }) | 300 | }) |
303 | }; | 301 | }; |
304 | 302 | ||
305 | let active_parameter = call_info.active_parameter.map(|it| it as i64); | 303 | let active_parameter = call_info.active_parameter.map(|it| it as u32); |
306 | 304 | ||
307 | let signature = lsp_types::SignatureInformation { | 305 | let signature = lsp_types::SignatureInformation { |
308 | label, | 306 | label, |
@@ -518,13 +516,13 @@ pub(crate) fn url_from_abs_path(path: &Path) -> lsp_types::Url { | |||
518 | lsp_types::Url::parse(&url).unwrap() | 516 | lsp_types::Url::parse(&url).unwrap() |
519 | } | 517 | } |
520 | 518 | ||
521 | pub(crate) fn versioned_text_document_identifier( | 519 | pub(crate) fn optional_versioned_text_document_identifier( |
522 | snap: &GlobalStateSnapshot, | 520 | snap: &GlobalStateSnapshot, |
523 | file_id: FileId, | 521 | file_id: FileId, |
524 | ) -> lsp_types::VersionedTextDocumentIdentifier { | 522 | ) -> lsp_types::OptionalVersionedTextDocumentIdentifier { |
525 | let url = url(snap, file_id); | 523 | let url = url(snap, file_id); |
526 | let version = snap.url_file_version(&url); | 524 | let version = snap.url_file_version(&url); |
527 | lsp_types::VersionedTextDocumentIdentifier { uri: url, version } | 525 | lsp_types::OptionalVersionedTextDocumentIdentifier { uri: url, version } |
528 | } | 526 | } |
529 | 527 | ||
530 | pub(crate) fn location( | 528 | pub(crate) fn location( |
@@ -613,7 +611,7 @@ pub(crate) fn snippet_text_document_edit( | |||
613 | is_snippet: bool, | 611 | is_snippet: bool, |
614 | source_file_edit: SourceFileEdit, | 612 | source_file_edit: SourceFileEdit, |
615 | ) -> Result<lsp_ext::SnippetTextDocumentEdit> { | 613 | ) -> Result<lsp_ext::SnippetTextDocumentEdit> { |
616 | let text_document = versioned_text_document_identifier(snap, source_file_edit.file_id); | 614 | let text_document = optional_versioned_text_document_identifier(snap, source_file_edit.file_id); |
617 | let line_index = snap.analysis.file_line_index(source_file_edit.file_id)?; | 615 | let line_index = snap.analysis.file_line_index(source_file_edit.file_id)?; |
618 | let line_endings = snap.file_line_endings(source_file_edit.file_id); | 616 | let line_endings = snap.file_line_endings(source_file_edit.file_id); |
619 | let edits = source_file_edit | 617 | let edits = source_file_edit |
diff --git a/crates/rust-analyzer/tests/rust-analyzer/support.rs b/crates/rust-analyzer/tests/rust-analyzer/support.rs index b210b98f0..456125789 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/support.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/support.rs | |||
@@ -108,7 +108,7 @@ pub(crate) fn project(fixture: &str) -> Server { | |||
108 | } | 108 | } |
109 | 109 | ||
110 | pub(crate) struct Server { | 110 | pub(crate) struct Server { |
111 | req_id: Cell<u64>, | 111 | req_id: Cell<i32>, |
112 | messages: RefCell<Vec<Message>>, | 112 | messages: RefCell<Vec<Message>>, |
113 | _thread: jod_thread::JoinHandle<()>, | 113 | _thread: jod_thread::JoinHandle<()>, |
114 | client: Connection, | 114 | client: Connection, |
@@ -165,7 +165,7 @@ impl Server { | |||
165 | R::Params: Serialize, | 165 | R::Params: Serialize, |
166 | { | 166 | { |
167 | let id = self.req_id.get(); | 167 | let id = self.req_id.get(); |
168 | self.req_id.set(id + 1); | 168 | self.req_id.set(id.wrapping_add(1)); |
169 | 169 | ||
170 | let r = Request::new(id.into(), R::METHOD.to_string(), params); | 170 | let r = Request::new(id.into(), R::METHOD.to_string(), params); |
171 | self.send_request_(r) | 171 | self.send_request_(r) |