mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Add field for text edits to InlayHint
This commit is contained in:
parent
ac03de773f
commit
fcbc250723
12 changed files with 54 additions and 7 deletions
|
@ -16,6 +16,7 @@ use syntax::{
|
|||
ast::{self, AstNode},
|
||||
match_ast, NodeOrToken, SyntaxNode, TextRange,
|
||||
};
|
||||
use text_edit::TextEdit;
|
||||
|
||||
use crate::{navigation_target::TryToNav, FileId};
|
||||
|
||||
|
@ -113,14 +114,26 @@ pub struct InlayHint {
|
|||
pub kind: InlayKind,
|
||||
/// The actual label to show in the inlay hint.
|
||||
pub label: InlayHintLabel,
|
||||
/// Text edit to apply when "accepting" this inlay hint.
|
||||
pub text_edit: Option<TextEdit>,
|
||||
}
|
||||
|
||||
impl InlayHint {
|
||||
fn closing_paren(range: TextRange) -> InlayHint {
|
||||
InlayHint { range, kind: InlayKind::ClosingParenthesis, label: InlayHintLabel::from(")") }
|
||||
InlayHint {
|
||||
range,
|
||||
kind: InlayKind::ClosingParenthesis,
|
||||
label: InlayHintLabel::from(")"),
|
||||
text_edit: None,
|
||||
}
|
||||
}
|
||||
fn opening_paren(range: TextRange) -> InlayHint {
|
||||
InlayHint { range, kind: InlayKind::OpeningParenthesis, label: InlayHintLabel::from("(") }
|
||||
InlayHint {
|
||||
range,
|
||||
kind: InlayKind::OpeningParenthesis,
|
||||
label: InlayHintLabel::from("("),
|
||||
text_edit: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue