specify completion item kind
This commit is contained in:
parent
284e894069
commit
328d123f5b
@ -18,7 +18,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
pub use crate::completion::completion_item::{CompletionItem, InsertText};
|
||||
pub use crate::completion::completion_item::{CompletionItem, InsertText, CompletionItemKind};
|
||||
|
||||
/// Main entry point for copmletion. We run comletion as a two-phase process.
|
||||
///
|
||||
|
@ -5,10 +5,11 @@ use ra_syntax::{
|
||||
SyntaxKind::*, SyntaxNodeRef,
|
||||
};
|
||||
|
||||
use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind};
|
||||
use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind};
|
||||
|
||||
fn keyword(kw: &str, snippet: &str) -> CompletionItem {
|
||||
CompletionItem::new(CompletionKind::Keyword, kw)
|
||||
.kind(CompletionItemKind::Keyword)
|
||||
.snippet(snippet)
|
||||
.build()
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext, completion_item::Builder};
|
||||
use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder};
|
||||
|
||||
fn snippet(label: &str, snippet: &str) -> Builder {
|
||||
CompletionItem::new(CompletionKind::Snippet, label).snippet(snippet)
|
||||
CompletionItem::new(CompletionKind::Snippet, label)
|
||||
.snippet(snippet)
|
||||
.kind(CompletionItemKind::Keyword)
|
||||
}
|
||||
|
||||
pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
|
@ -3,13 +3,13 @@
|
||||
/// `CompletionItem`, use `new` method and the `Builder` struct.
|
||||
#[derive(Debug)]
|
||||
pub struct CompletionItem {
|
||||
/// Used only internally in tests, to check only specific kind of
|
||||
/// completion.
|
||||
completion_kind: CompletionKind,
|
||||
label: String,
|
||||
lookup: Option<String>,
|
||||
snippet: Option<String>,
|
||||
kind: Option<CompletionItemKind>,
|
||||
/// Used only internally in tests, to check only specific kind of
|
||||
/// completion.
|
||||
completion_kind: CompletionKind,
|
||||
}
|
||||
|
||||
pub enum InsertText {
|
||||
@ -38,10 +38,11 @@ impl CompletionItem {
|
||||
pub(crate) fn new(completion_kind: CompletionKind, label: impl Into<String>) -> Builder {
|
||||
let label = label.into();
|
||||
Builder {
|
||||
completion_kind,
|
||||
label,
|
||||
lookup: None,
|
||||
snippet: None,
|
||||
completion_kind,
|
||||
kind: None,
|
||||
}
|
||||
}
|
||||
/// What user sees in pop-up in the UI.
|
||||
@ -73,10 +74,11 @@ impl CompletionItem {
|
||||
/// A helper to make `CompletionItem`s.
|
||||
#[must_use]
|
||||
pub(crate) struct Builder {
|
||||
completion_kind: CompletionKind,
|
||||
label: String,
|
||||
lookup: Option<String>,
|
||||
snippet: Option<String>,
|
||||
completion_kind: CompletionKind,
|
||||
kind: Option<CompletionItemKind>,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
@ -89,7 +91,7 @@ impl Builder {
|
||||
label: self.label,
|
||||
lookup: self.lookup,
|
||||
snippet: self.snippet,
|
||||
kind: None,
|
||||
kind: self.kind,
|
||||
completion_kind: self.completion_kind,
|
||||
}
|
||||
}
|
||||
@ -101,8 +103,8 @@ impl Builder {
|
||||
self.snippet = Some(snippet.into());
|
||||
self
|
||||
}
|
||||
pub(crate) fn kind(mut self, kind: CompletionKind) -> Builder {
|
||||
self.completion_kind = kind;
|
||||
pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder {
|
||||
self.kind = Some(kind);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user