From 6d2d27938985e210d5b5e561df8a48be20343be7 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 30 Nov 2020 22:28:19 +0200 Subject: Working resolve completion imports prototype --- crates/completion/src/item.rs | 14 +++++++++----- crates/completion/src/lib.rs | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'crates/completion') diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index ce6a44e57..0e59f73cb 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs @@ -257,14 +257,18 @@ impl CompletionItem { pub fn ref_match(&self) -> Option<(Mutability, CompletionScore)> { self.ref_match } + + pub fn import_to_add(&self) -> Option<&ImportToAdd> { + self.import_to_add.as_ref() + } } /// An extra import to add after the completion is applied. -#[derive(Clone)] -pub(crate) struct ImportToAdd { - pub(crate) import_path: ModPath, - pub(crate) import_scope: ImportScope, - pub(crate) merge_behaviour: Option, +#[derive(Debug, Clone)] +pub struct ImportToAdd { + pub import_path: ModPath, + pub import_scope: ImportScope, + pub merge_behaviour: Option, } /// A helper to make `CompletionItem`s. diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index 1ec2e9be7..28209d4e0 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs @@ -18,7 +18,7 @@ use crate::{completions::Completions, context::CompletionContext, item::Completi pub use crate::{ config::CompletionConfig, - item::{CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat}, + item::{CompletionItem, CompletionItemKind, CompletionScore, ImportToAdd, InsertTextFormat}, }; //FIXME: split the following feature into fine-grained features. -- cgit v1.2.3