diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-24 21:31:44 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-24 21:31:44 +0100 |
commit | a09a00a56049c705dcddc33773a27d5ce976b02e (patch) | |
tree | 442cd510e65defcc8a7ef0d1ed2a20b1e7cfef08 /crates/rust-analyzer/src/main_loop.rs | |
parent | 18172eb1972717d108969710f2bce10c018e98c9 (diff) | |
parent | 48da2d4c16a05bf0559c864d2b3f1b832d1fec85 (diff) |
Merge #5520
5520: Add DocumentData to represent in-memory document with LSP info r=matklad a=kjeremy
At the moment this only holds document version information but in the near-future it will hold other things like semantic token delta info.
Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e95d4157c..51626fcd5 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -15,6 +15,7 @@ use ra_prof::profile; | |||
15 | use crate::{ | 15 | use crate::{ |
16 | config::Config, | 16 | config::Config, |
17 | dispatch::{NotificationDispatcher, RequestDispatcher}, | 17 | dispatch::{NotificationDispatcher, RequestDispatcher}, |
18 | document::DocumentData, | ||
18 | from_proto, | 19 | from_proto, |
19 | global_state::{file_id_to_url, url_to_file_id, GlobalState, Status}, | 20 | global_state::{file_id_to_url, url_to_file_id, GlobalState, Status}, |
20 | handlers, lsp_ext, | 21 | handlers, lsp_ext, |
@@ -311,7 +312,7 @@ impl GlobalState { | |||
311 | let url = file_id_to_url(&self.vfs.read().0, file_id); | 312 | let url = file_id_to_url(&self.vfs.read().0, file_id); |
312 | let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect(); | 313 | let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect(); |
313 | let version = from_proto::vfs_path(&url) | 314 | let version = from_proto::vfs_path(&url) |
314 | .map(|path| self.mem_docs.get(&path).copied().flatten()) | 315 | .map(|path| self.mem_docs.get(&path)?.version) |
315 | .unwrap_or_default(); | 316 | .unwrap_or_default(); |
316 | 317 | ||
317 | self.send_notification::<lsp_types::notification::PublishDiagnostics>( | 318 | self.send_notification::<lsp_types::notification::PublishDiagnostics>( |
@@ -406,7 +407,7 @@ impl GlobalState { | |||
406 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { | 407 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { |
407 | if this | 408 | if this |
408 | .mem_docs | 409 | .mem_docs |
409 | .insert(path.clone(), Some(params.text_document.version)) | 410 | .insert(path.clone(), DocumentData::new(params.text_document.version)) |
410 | .is_some() | 411 | .is_some() |
411 | { | 412 | { |
412 | log::error!("duplicate DidOpenTextDocument: {}", path) | 413 | log::error!("duplicate DidOpenTextDocument: {}", path) |
@@ -428,7 +429,7 @@ impl GlobalState { | |||
428 | 429 | ||
429 | // The version passed in DidChangeTextDocument is the version after all edits are applied | 430 | // The version passed in DidChangeTextDocument is the version after all edits are applied |
430 | // so we should apply it before the vfs is notified. | 431 | // so we should apply it before the vfs is notified. |
431 | *doc = params.text_document.version; | 432 | doc.version = params.text_document.version; |
432 | 433 | ||
433 | vfs.set_file_contents(path.clone(), Some(text.into_bytes())); | 434 | vfs.set_file_contents(path.clone(), Some(text.into_bytes())); |
434 | } | 435 | } |
@@ -438,7 +439,7 @@ impl GlobalState { | |||
438 | let mut version = None; | 439 | let mut version = None; |
439 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { | 440 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { |
440 | match this.mem_docs.remove(&path) { | 441 | match this.mem_docs.remove(&path) { |
441 | Some(entry) => version = entry, | 442 | Some(doc) => version = doc.version, |
442 | None => log::error!("orphan DidCloseTextDocument: {}", path), | 443 | None => log::error!("orphan DidCloseTextDocument: {}", path), |
443 | } | 444 | } |
444 | 445 | ||