Add field for text edits to InlayHint

This commit is contained in:
Ryo Yoshida 2023-04-06 18:53:34 +09:00
parent ac03de773f
commit fcbc250723
No known key found for this signature in database
GPG key ID: E25698A930586171
12 changed files with 54 additions and 7 deletions

View file

@ -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,
}
}
}