mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
internal: make CompletionItem and SourceChange consistent
Before this PR, SourceChange used a bool and CompletionItem used an enum to signify if edit is a snippet. It makes sense to use the same pattern in both cases. `bool` feels simpler, as there's only one consumer of this API, and all producers are encapsulated anyway (we check the capability at the production site).
This commit is contained in:
parent
2ce88b504c
commit
6e9780c005
4 changed files with 16 additions and 31 deletions
|
@ -9,8 +9,8 @@ use ide::{
|
|||
Annotation, AnnotationKind, Assist, AssistKind, CallInfo, Cancellable, CompletionItem,
|
||||
CompletionItemKind, CompletionRelevance, Documentation, FileId, FileRange, FileSystemEdit,
|
||||
Fold, FoldKind, Highlight, HlMod, HlOperator, HlPunct, HlRange, HlTag, Indel, InlayHint,
|
||||
InlayKind, InsertTextFormat, Markup, NavigationTarget, ReferenceAccess, RenameError, Runnable,
|
||||
Severity, SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
|
||||
InlayKind, Markup, NavigationTarget, ReferenceAccess, RenameError, Runnable, Severity,
|
||||
SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use serde_json::to_value;
|
||||
|
@ -92,15 +92,6 @@ pub(crate) fn documentation(documentation: Documentation) -> lsp_types::Document
|
|||
lsp_types::Documentation::MarkupContent(markup_content)
|
||||
}
|
||||
|
||||
pub(crate) fn insert_text_format(
|
||||
insert_text_format: InsertTextFormat,
|
||||
) -> lsp_types::InsertTextFormat {
|
||||
match insert_text_format {
|
||||
InsertTextFormat::Snippet => lsp_types::InsertTextFormat::Snippet,
|
||||
InsertTextFormat::PlainText => lsp_types::InsertTextFormat::PlainText,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn completion_item_kind(
|
||||
completion_item_kind: CompletionItemKind,
|
||||
) -> lsp_types::CompletionItemKind {
|
||||
|
@ -278,7 +269,9 @@ fn completion_item(
|
|||
lsp_item.command = Some(command::trigger_parameter_hints());
|
||||
}
|
||||
|
||||
lsp_item.insert_text_format = Some(insert_text_format(item.insert_text_format()));
|
||||
if item.is_snippet() {
|
||||
lsp_item.insert_text_format = Some(lsp_types::InsertTextFormat::Snippet);
|
||||
}
|
||||
if enable_imports_on_the_fly {
|
||||
if let Some(import_edit) = item.import_to_add() {
|
||||
let import_path = &import_edit.import.import_path;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue