Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/tests.rs')
| -rw-r--r-- | crates/ide-assists/src/tests.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs index 48d2af6d3f..87851e445d 100644 --- a/crates/ide-assists/src/tests.rs +++ b/crates/ide-assists/src/tests.rs @@ -34,6 +34,26 @@ pub(crate) const TEST_CONFIG: AssistConfig = AssistConfig { assist_emit_must_use: false, term_search_fuel: 400, term_search_borrowck: true, + code_action_grouping: true, +}; + +pub(crate) const TEST_CONFIG_NO_GROUPING: AssistConfig = AssistConfig { + snippet_cap: SnippetCap::new(true), + allowed: None, + insert_use: InsertUseConfig { + granularity: ImportGranularity::Crate, + prefix_kind: hir::PrefixKind::Plain, + enforce_granularity: true, + group: true, + skip_glob_imports: true, + }, + prefer_no_std: false, + prefer_prelude: true, + prefer_absolute: false, + assist_emit_must_use: false, + term_search_fuel: 400, + term_search_borrowck: true, + code_action_grouping: false, }; pub(crate) const TEST_CONFIG_NO_SNIPPET_CAP: AssistConfig = AssistConfig { @@ -52,6 +72,7 @@ pub(crate) const TEST_CONFIG_NO_SNIPPET_CAP: AssistConfig = AssistConfig { assist_emit_must_use: false, term_search_fuel: 400, term_search_borrowck: true, + code_action_grouping: true, }; pub(crate) const TEST_CONFIG_IMPORT_ONE: AssistConfig = AssistConfig { @@ -70,6 +91,7 @@ pub(crate) const TEST_CONFIG_IMPORT_ONE: AssistConfig = AssistConfig { assist_emit_must_use: false, term_search_fuel: 400, term_search_borrowck: true, + code_action_grouping: true, }; pub(crate) fn with_single_file(text: &str) -> (RootDatabase, EditionedFileId) { @@ -347,6 +369,41 @@ fn labels(assists: &[Assist]) -> String { } #[test] +fn long_groups_are_skipped_under_skip_resolve_strategy() { + let before = r#" +trait SomeTrait { + type T; + fn fn_(arg: u32) -> u32; + fn method_(&mut self) -> bool; +} +struct A; +impl SomeTrait for A { + type T = u32; + + fn fn_(arg: u32) -> u32 { + 42 + } + + fn method_(&mut self) -> bool { + false + } +} +struct B { + a$0 : A, +} + "#; + let (before_cursor_pos, before) = extract_offset(before); + let (db, file_id) = with_single_file(&before); + let frange = FileRange { file_id, range: TextRange::empty(before_cursor_pos) }; + let res = assists(&db, &TEST_CONFIG, AssistResolveStrategy::None, frange.into()); + assert!(res.iter().map(|a| &a.id).any(|a| { a.0 == "generate_delegate_trait" })); + + let limited = + assists(&db, &TEST_CONFIG_NO_GROUPING, AssistResolveStrategy::None, frange.into()); + assert!(!limited.iter().map(|a| &a.id).any(|a| { a.0 == "generate_delegate_trait" })); +} + +#[test] fn assist_order_field_struct() { let before = "struct Foo { $0bar: u32 }"; let (before_cursor_pos, before) = extract_offset(before); |