]> git.lizzy.rs Git - rust.git/blobdiff - crates/rust-analyzer/src/main_loop.rs
internal: prepare to track changes to mem_docs
[rust.git] / crates / rust-analyzer / src / main_loop.rs
index 8aaca47160386b730cd436088f4741a64e83769e..0518a17f3073885f31ce24d23dadd67a9a9b02c7 100644 (file)
 use crate::{
     config::Config,
     dispatch::{NotificationDispatcher, RequestDispatcher},
-    document::DocumentData,
     from_proto,
     global_state::{file_id_to_url, url_to_file_id, GlobalState},
     handlers, lsp_ext,
     lsp_utils::{apply_document_changes, is_cancelled, notification_is, Progress},
+    mem_docs::DocumentData,
     reload::{BuildDataProgress, ProjectWorkspaceProgress},
     Result,
 };
@@ -305,7 +305,7 @@ fn handle_event(&mut self, event: Event) -> Result<()> {
                             let vfs = &mut self.vfs.write().0;
                             for (path, contents) in files {
                                 let path = VfsPath::from(path);
-                                if !self.mem_docs.contains_key(&path) {
+                                if !self.mem_docs.contains(&path) {
                                     vfs.set_file_contents(path, contents);
                                 }
                             }
@@ -582,7 +582,7 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
                     if this
                         .mem_docs
                         .insert(path.clone(), DocumentData::new(params.text_document.version))
-                        .is_some()
+                        .is_err()
                     {
                         log::error!("duplicate DidOpenTextDocument: {}", path)
                     }
@@ -628,7 +628,7 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
             })?
             .on::<lsp_types::notification::DidCloseTextDocument>(|this, params| {
                 if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
-                    if this.mem_docs.remove(&path).is_none() {
+                    if this.mem_docs.remove(&path).is_err() {
                         log::error!("orphan DidCloseTextDocument: {}", path);
                     }
 
@@ -719,7 +719,7 @@ fn update_file_notifications_on_threadpool(&mut self) {
     fn maybe_update_diagnostics(&mut self) {
         let subscriptions = self
             .mem_docs
-            .keys()
+            .iter()
             .map(|path| self.vfs.read().0.file_id(path).unwrap())
             .collect::<Vec<_>>();