Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints.rs')
-rw-r--r--crates/ide/src/inlay_hints.rs39
1 files changed, 13 insertions, 26 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index e82d730e4a..f466b8e938 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -32,6 +32,7 @@ mod fn_lifetime_fn;
mod implicit_static;
mod param_name;
mod implicit_drop;
+mod range_exclusive;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InlayHintsConfig {
@@ -51,6 +52,7 @@ pub struct InlayHintsConfig {
pub param_names_for_lifetime_elision_hints: bool,
pub hide_named_constructor_hints: bool,
pub hide_closure_initialization_hints: bool,
+ pub range_exclusive_hints: bool,
pub closure_style: ClosureStyle,
pub max_length: Option<usize>,
pub closing_brace_hints_min_lines: Option<usize>,
@@ -127,6 +129,7 @@ pub enum InlayKind {
Parameter,
Type,
Drop,
+ RangeExclusive,
}
#[derive(Debug)]
@@ -517,13 +520,20 @@ fn hints(
closure_captures::hints(hints, famous_defs, config, file_id, it.clone());
closure_ret::hints(hints, famous_defs, config, file_id, it)
},
+ ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, config, it),
_ => None,
}
},
ast::Pat(it) => {
binding_mode::hints(hints, sema, config, &it);
- if let ast::Pat::IdentPat(it) = it {
- bind_pat::hints(hints, famous_defs, config, file_id, &it);
+ match it {
+ ast::Pat::IdentPat(it) => {
+ bind_pat::hints(hints, famous_defs, config, file_id, &it);
+ }
+ ast::Pat::RangePat(it) => {
+ range_exclusive::hints(hints, config, it);
+ }
+ _ => {}
}
Some(())
},
@@ -593,7 +603,6 @@ mod tests {
use hir::ClosureStyle;
use itertools::Itertools;
use test_utils::extract_annotations;
- use text_edit::{TextRange, TextSize};
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
use crate::DiscriminantHints;
@@ -622,6 +631,7 @@ mod tests {
closing_brace_hints_min_lines: None,
fields_to_resolve: InlayFieldsToResolve::empty(),
implicit_drop_hints: false,
+ range_exclusive_hints: false,
};
pub(super) const TEST_CONFIG: InlayHintsConfig = InlayHintsConfig {
type_hints: true,
@@ -654,29 +664,6 @@ mod tests {
assert_eq!(expected, actual, "\nExpected:\n{expected:#?}\n\nActual:\n{actual:#?}");
}
- #[track_caller]
- pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
- let (analysis, file_id) = fixture::file(ra_fixture);
- let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
- expect.assert_debug_eq(&inlay_hints)
- }
-
- #[track_caller]
- pub(super) fn check_expect_clear_loc(
- config: InlayHintsConfig,
- ra_fixture: &str,
- expect: Expect,
- ) {
- let (analysis, file_id) = fixture::file(ra_fixture);
- let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
- inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
- if let Some(loc) = &mut hint.linked_location {
- loc.range = TextRange::empty(TextSize::from(0));
- }
- });
- expect.assert_debug_eq(&inlay_hints)
- }
-
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
/// expect test.
#[track_caller]