mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
move completion items to conv
This commit is contained in:
parent
328d123f5b
commit
f1f2804c71
5 changed files with 33 additions and 30 deletions
|
@ -1,8 +1,8 @@
|
|||
use languageserver_types::{
|
||||
self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier,
|
||||
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier,
|
||||
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, InsertTextFormat,
|
||||
};
|
||||
use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition};
|
||||
use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition, CompletionItem, InsertText};
|
||||
use ra_editor::{LineCol, LineIndex};
|
||||
use ra_text_edit::{AtomTextEdit, TextEdit};
|
||||
use ra_syntax::{SyntaxKind, TextRange, TextUnit};
|
||||
|
@ -45,6 +45,30 @@ impl Conv for SyntaxKind {
|
|||
}
|
||||
}
|
||||
|
||||
impl Conv for CompletionItem {
|
||||
type Output = ::languageserver_types::CompletionItem;
|
||||
|
||||
fn conv(self) -> <Self as Conv>::Output {
|
||||
let mut res = ::languageserver_types::CompletionItem {
|
||||
label: self.label().to_string(),
|
||||
filter_text: Some(self.lookup().to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
match self.insert_text() {
|
||||
InsertText::PlainText { text } => {
|
||||
res.insert_text = Some(text);
|
||||
res.insert_text_format = Some(InsertTextFormat::PlainText);
|
||||
}
|
||||
InsertText::Snippet { text } => {
|
||||
res.insert_text = Some(text);
|
||||
res.insert_text_format = Some(InsertTextFormat::Snippet);
|
||||
res.kind = Some(languageserver_types::CompletionItemKind::Keyword);
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl ConvWith for Position {
|
||||
type Ctx = LineIndex;
|
||||
type Output = TextUnit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue