Add default method for CompletionProvider::resolve_completions (#32045)
Release Notes: - N/A
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
use std::cell::RefCell;
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::AtomicBool;
|
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(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
@@ -1077,7 +1065,7 @@ mod tests {
|
|||||||
use project::{Project, ProjectPath};
|
use project::{Project, ProjectPath};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use std::ops::Deref;
|
use std::{ops::Deref, rc::Rc};
|
||||||
use util::{path, separator};
|
use util::{path, separator};
|
||||||
use workspace::{AppState, Item};
|
use workspace::{AppState, Item};
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ use parking_lot::Mutex;
|
|||||||
use project::{CompletionIntent, CompletionSource, lsp_store::CompletionDocumentation};
|
use project::{CompletionIntent, CompletionSource, lsp_store::CompletionDocumentation};
|
||||||
use rope::Point;
|
use rope::Point;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
|
||||||
ops::Range,
|
ops::Range,
|
||||||
rc::Rc,
|
|
||||||
sync::{
|
sync::{
|
||||||
Arc,
|
Arc,
|
||||||
atomic::{AtomicBool, Ordering::SeqCst},
|
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(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
buffer: &Entity<Buffer>,
|
buffer: &Entity<Buffer>,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use language::{
|
|||||||
use project::{Completion, CompletionResponse, CompletionSource, search::SearchQuery};
|
use project::{Completion, CompletionResponse, CompletionSource, search::SearchQuery};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
|
||||||
ops::Range,
|
ops::Range,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::{Arc, LazyLock},
|
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(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
_buffer: &Entity<Buffer>,
|
_buffer: &Entity<Buffer>,
|
||||||
@@ -255,7 +244,7 @@ impl MessageEditor {
|
|||||||
{
|
{
|
||||||
if !candidates.is_empty() {
|
if !candidates.is_empty() {
|
||||||
return cx.spawn(async move |_, cx| {
|
return cx.spawn(async move |_, cx| {
|
||||||
let completion_response = Self::resolve_completions_for_candidates(
|
let completion_response = Self::completions_for_candidates(
|
||||||
&cx,
|
&cx,
|
||||||
query.as_str(),
|
query.as_str(),
|
||||||
&candidates,
|
&candidates,
|
||||||
@@ -273,7 +262,7 @@ impl MessageEditor {
|
|||||||
{
|
{
|
||||||
if !candidates.is_empty() {
|
if !candidates.is_empty() {
|
||||||
return cx.spawn(async move |_, cx| {
|
return cx.spawn(async move |_, cx| {
|
||||||
let completion_response = Self::resolve_completions_for_candidates(
|
let completion_response = Self::completions_for_candidates(
|
||||||
&cx,
|
&cx,
|
||||||
query.as_str(),
|
query.as_str(),
|
||||||
candidates,
|
candidates,
|
||||||
@@ -292,7 +281,7 @@ impl MessageEditor {
|
|||||||
}]))
|
}]))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn resolve_completions_for_candidates(
|
async fn completions_for_candidates(
|
||||||
cx: &AsyncApp,
|
cx: &AsyncApp,
|
||||||
query: &str,
|
query: &str,
|
||||||
candidates: &[StringMatchCandidate],
|
candidates: &[StringMatchCandidate],
|
||||||
|
|||||||
@@ -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(
|
fn apply_additional_edits_for_completion(
|
||||||
&self,
|
&self,
|
||||||
_buffer: Entity<Buffer>,
|
_buffer: Entity<Buffer>,
|
||||||
|
|||||||
@@ -20325,11 +20325,13 @@ pub trait CompletionProvider {
|
|||||||
|
|
||||||
fn resolve_completions(
|
fn resolve_completions(
|
||||||
&self,
|
&self,
|
||||||
buffer: Entity<Buffer>,
|
_buffer: Entity<Buffer>,
|
||||||
completion_indices: Vec<usize>,
|
_completion_indices: Vec<usize>,
|
||||||
completions: Rc<RefCell<Box<[Completion]>>>,
|
_completions: Rc<RefCell<Box<[Completion]>>>,
|
||||||
cx: &mut Context<Editor>,
|
_cx: &mut Context<Editor>,
|
||||||
) -> Task<Result<bool>>;
|
) -> Task<Result<bool>> {
|
||||||
|
Task::ready(Ok(false))
|
||||||
|
}
|
||||||
|
|
||||||
fn apply_additional_edits_for_completion(
|
fn apply_additional_edits_for_completion(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use language::{
|
|||||||
};
|
};
|
||||||
use project::lsp_store::CompletionDocumentation;
|
use project::lsp_store::CompletionDocumentation;
|
||||||
use project::{Completion, CompletionResponse, CompletionSource, Project, ProjectPath};
|
use project::{Completion, CompletionResponse, CompletionSource, Project, ProjectPath};
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::fmt::Write as _;
|
use std::fmt::Write as _;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::Path;
|
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(
|
fn is_completion_trigger(
|
||||||
&self,
|
&self,
|
||||||
buffer: &Entity<language::Buffer>,
|
buffer: &Entity<language::Buffer>,
|
||||||
|
|||||||
Reference in New Issue
Block a user