Add default method for `CompletionProvider::resolve_completions` (#32045)

Michael Sloan created

Release Notes:

- N/A

Change summary

crates/agent/src/context_picker/completion_provider.rs | 14 ---------
crates/assistant_context_editor/src/slash_command.rs   | 12 --------
crates/collab_ui/src/chat_panel/message_editor.rs      | 17 ++---------
crates/debugger_ui/src/session/running/console.rs      | 10 -------
crates/editor/src/editor.rs                            | 12 ++++---
crates/inspector_ui/src/div_inspector.rs               | 11 -------
6 files changed, 11 insertions(+), 65 deletions(-)

Detailed changes

crates/agent/src/context_picker/completion_provider.rs 🔗

@@ -1,7 +1,5 @@
-use std::cell::RefCell;
 use std::ops::Range;
 use std::path::{Path, PathBuf};
-use std::rc::Rc;
 use std::sync::Arc;
 use std::sync::atomic::AtomicBool;
 
@@ -912,16 +910,6 @@ impl CompletionProvider for ContextPickerCompletionProvider {
         })
     }
 
-    fn resolve_completions(
-        &self,
-        _buffer: Entity<Buffer>,
-        _completion_indices: Vec<usize>,
-        _completions: Rc<RefCell<Box<[Completion]>>>,
-        _cx: &mut Context<Editor>,
-    ) -> Task<Result<bool>> {
-        Task::ready(Ok(true))
-    }
-
     fn is_completion_trigger(
         &self,
         buffer: &Entity<language::Buffer>,
@@ -1077,7 +1065,7 @@ mod tests {
     use project::{Project, ProjectPath};
     use serde_json::json;
     use settings::SettingsStore;
-    use std::ops::Deref;
+    use std::{ops::Deref, rc::Rc};
     use util::{path, separator};
     use workspace::{AppState, Item};
 

crates/assistant_context_editor/src/slash_command.rs 🔗

@@ -10,9 +10,7 @@ use parking_lot::Mutex;
 use project::{CompletionIntent, CompletionSource, lsp_store::CompletionDocumentation};
 use rope::Point;
 use std::{
-    cell::RefCell,
     ops::Range,
-    rc::Rc,
     sync::{
         Arc,
         atomic::{AtomicBool, Ordering::SeqCst},
@@ -326,16 +324,6 @@ impl CompletionProvider for SlashCommandCompletionProvider {
         }
     }
 
-    fn resolve_completions(
-        &self,
-        _: Entity<Buffer>,
-        _: Vec<usize>,
-        _: Rc<RefCell<Box<[project::Completion]>>>,
-        _: &mut Context<Editor>,
-    ) -> Task<Result<bool>> {
-        Task::ready(Ok(true))
-    }
-
     fn is_completion_trigger(
         &self,
         buffer: &Entity<Buffer>,

crates/collab_ui/src/chat_panel/message_editor.rs 🔗

@@ -15,7 +15,6 @@ use language::{
 use project::{Completion, CompletionResponse, CompletionSource, search::SearchQuery};
 use settings::Settings;
 use std::{
-    cell::RefCell,
     ops::Range,
     rc::Rc,
     sync::{Arc, LazyLock},
@@ -73,16 +72,6 @@ impl CompletionProvider for MessageEditorCompletionProvider {
         })
     }
 
-    fn resolve_completions(
-        &self,
-        _buffer: Entity<Buffer>,
-        _completion_indices: Vec<usize>,
-        _completions: Rc<RefCell<Box<[Completion]>>>,
-        _cx: &mut Context<Editor>,
-    ) -> Task<anyhow::Result<bool>> {
-        Task::ready(Ok(false))
-    }
-
     fn is_completion_trigger(
         &self,
         _buffer: &Entity<Buffer>,
@@ -255,7 +244,7 @@ impl MessageEditor {
         {
             if !candidates.is_empty() {
                 return cx.spawn(async move |_, cx| {
-                    let completion_response = Self::resolve_completions_for_candidates(
+                    let completion_response = Self::completions_for_candidates(
                         &cx,
                         query.as_str(),
                         &candidates,
@@ -273,7 +262,7 @@ impl MessageEditor {
         {
             if !candidates.is_empty() {
                 return cx.spawn(async move |_, cx| {
-                    let completion_response = Self::resolve_completions_for_candidates(
+                    let completion_response = Self::completions_for_candidates(
                         &cx,
                         query.as_str(),
                         candidates,
@@ -292,7 +281,7 @@ impl MessageEditor {
         }]))
     }
 
-    async fn resolve_completions_for_candidates(
+    async fn completions_for_candidates(
         cx: &AsyncApp,
         query: &str,
         candidates: &[StringMatchCandidate],

crates/debugger_ui/src/session/running/console.rs 🔗

@@ -282,16 +282,6 @@ impl CompletionProvider for ConsoleQueryBarCompletionProvider {
         }
     }
 
-    fn resolve_completions(
-        &self,
-        _buffer: Entity<Buffer>,
-        _completion_indices: Vec<usize>,
-        _completions: Rc<RefCell<Box<[Completion]>>>,
-        _cx: &mut Context<Editor>,
-    ) -> gpui::Task<anyhow::Result<bool>> {
-        Task::ready(Ok(false))
-    }
-
     fn apply_additional_edits_for_completion(
         &self,
         _buffer: Entity<Buffer>,

crates/editor/src/editor.rs 🔗

@@ -20325,11 +20325,13 @@ pub trait CompletionProvider {
 
     fn resolve_completions(
         &self,
-        buffer: Entity<Buffer>,
-        completion_indices: Vec<usize>,
-        completions: Rc<RefCell<Box<[Completion]>>>,
-        cx: &mut Context<Editor>,
-    ) -> Task<Result<bool>>;
+        _buffer: Entity<Buffer>,
+        _completion_indices: Vec<usize>,
+        _completions: Rc<RefCell<Box<[Completion]>>>,
+        _cx: &mut Context<Editor>,
+    ) -> Task<Result<bool>> {
+        Task::ready(Ok(false))
+    }
 
     fn apply_additional_edits_for_completion(
         &self,

crates/inspector_ui/src/div_inspector.rs 🔗

@@ -12,7 +12,6 @@ use language::{
 };
 use project::lsp_store::CompletionDocumentation;
 use project::{Completion, CompletionResponse, CompletionSource, Project, ProjectPath};
-use std::cell::RefCell;
 use std::fmt::Write as _;
 use std::ops::Range;
 use std::path::Path;
@@ -671,16 +670,6 @@ impl CompletionProvider for RustStyleCompletionProvider {
         }]))
     }
 
-    fn resolve_completions(
-        &self,
-        _buffer: Entity<Buffer>,
-        _completion_indices: Vec<usize>,
-        _completions: Rc<RefCell<Box<[Completion]>>>,
-        _cx: &mut Context<Editor>,
-    ) -> Task<Result<bool>> {
-        Task::ready(Ok(true))
-    }
-
     fn is_completion_trigger(
         &self,
         buffer: &Entity<language::Buffer>,