mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-07 20:43:03 +00:00
Add a test for disabled argument snippets
This commit is contained in:
parent
0714a065d5
commit
9b0b59c5d2
@ -20,7 +20,7 @@ mod complete_trait_impl;
|
||||
use ra_ide_db::RootDatabase;
|
||||
|
||||
#[cfg(test)]
|
||||
use crate::completion::completion_item::do_completion;
|
||||
use crate::completion::completion_item::{do_completion, do_completion_with_options};
|
||||
use crate::{
|
||||
completion::{
|
||||
completion_context::CompletionContext,
|
||||
|
@ -321,8 +321,17 @@ impl Into<Vec<CompletionItem>> for Completions {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
|
||||
do_completion_with_options(code, kind, &crate::completion::CompletionOptions::default())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn do_completion_with_options(
|
||||
code: &str,
|
||||
kind: CompletionKind,
|
||||
options: &crate::completion::CompletionOptions,
|
||||
) -> Vec<CompletionItem> {
|
||||
use crate::{
|
||||
completion::{completions, CompletionOptions},
|
||||
completion::completions,
|
||||
mock_analysis::{analysis_and_position, single_file_with_position},
|
||||
};
|
||||
|
||||
@ -331,7 +340,6 @@ pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionI
|
||||
} else {
|
||||
single_file_with_position(code)
|
||||
};
|
||||
let options = CompletionOptions::default();
|
||||
let completions = completions(&analysis.db, position, &options).unwrap();
|
||||
let completion_items: Vec<CompletionItem> = completions.into();
|
||||
let mut kind_completions: Vec<CompletionItem> =
|
||||
|
@ -307,12 +307,22 @@ mod tests {
|
||||
use insta::assert_debug_snapshot;
|
||||
use test_utils::covers;
|
||||
|
||||
use crate::completion::{do_completion, CompletionItem, CompletionKind};
|
||||
use crate::completion::{
|
||||
do_completion, do_completion_with_options, CompletionItem, CompletionKind,
|
||||
CompletionOptions,
|
||||
};
|
||||
|
||||
fn do_reference_completion(ra_fixture: &str) -> Vec<CompletionItem> {
|
||||
do_completion(ra_fixture, CompletionKind::Reference)
|
||||
}
|
||||
|
||||
fn do_reference_completion_with_options(
|
||||
ra_fixture: &str,
|
||||
options: CompletionOptions,
|
||||
) -> Vec<CompletionItem> {
|
||||
do_completion_with_options(ra_fixture, CompletionKind::Reference, &options)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_detail_includes_names_for_record() {
|
||||
assert_debug_snapshot!(
|
||||
@ -533,7 +543,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parens_for_method_call() {
|
||||
fn arg_snippets_for_method_call() {
|
||||
assert_debug_snapshot!(
|
||||
do_reference_completion(
|
||||
r"
|
||||
@ -562,6 +572,40 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_arg_snippets_for_method_call() {
|
||||
assert_debug_snapshot!(
|
||||
do_reference_completion_with_options(
|
||||
r"
|
||||
struct S {}
|
||||
impl S {
|
||||
fn foo(&self, x: i32) {}
|
||||
}
|
||||
fn bar(s: &S) {
|
||||
s.f<|>
|
||||
}
|
||||
",
|
||||
CompletionOptions {
|
||||
add_call_argument_snippets: false,
|
||||
.. Default::default()
|
||||
}
|
||||
),
|
||||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
source_range: [171; 172),
|
||||
delete: [171; 172),
|
||||
insert: "foo($0)",
|
||||
kind: Method,
|
||||
lookup: "foo",
|
||||
detail: "fn foo(&self, x: i32)",
|
||||
},
|
||||
]
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_render_function_parens_in_use_item() {
|
||||
assert_debug_snapshot!(
|
||||
|
Loading…
Reference in New Issue
Block a user