Use upstream cov-mark

This commit is contained in:
Laurențiu Nicola
2021-03-08 22:19:44 +02:00
parent c5189a22cc
commit fc9eed4836
101 changed files with 354 additions and 514 deletions

View File

@@ -1,7 +1,6 @@
//! Extensions for `Builder` structure required for item rendering.
use itertools::Itertools;
use test_utils::mark;
use crate::{item::Builder, CompletionContext};
@@ -30,7 +29,7 @@ impl Builder {
return false;
}
if ctx.use_item_syntax.is_some() {
mark::hit!(no_parens_in_use_item);
cov_mark::hit!(no_parens_in_use_item);
return false;
}
if ctx.is_pattern_call {
@@ -43,7 +42,7 @@ impl Builder {
// Don't add parentheses if the expected type is some function reference.
if let Some(ty) = &ctx.expected_type {
if ty.is_fn() {
mark::hit!(no_call_parens_if_fn_ptr_needed);
cov_mark::hit!(no_call_parens_if_fn_ptr_needed);
return false;
}
}
@@ -67,7 +66,7 @@ impl Builder {
None => return self,
};
// If not an import, add parenthesis automatically.
mark::hit!(inserts_parens_for_function_calls);
cov_mark::hit!(inserts_parens_for_function_calls);
let (snippet, label) = if params.is_empty() {
(format!("{}()$0", name), format!("{}()", name))
@@ -82,7 +81,7 @@ impl Builder {
format!("{}({})$0", name, function_params_snippet)
}
_ => {
mark::hit!(suppress_arg_snippets);
cov_mark::hit!(suppress_arg_snippets);
format!("{}($0)", name)
}
};

View File

@@ -3,7 +3,6 @@
use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
use ide_db::SymbolKind;
use itertools::Itertools;
use test_utils::mark;
use crate::{
item::{CompletionItem, CompletionKind, ImportEdit},
@@ -68,7 +67,7 @@ impl<'a> EnumRender<'a> {
.detail(self.detail());
if self.variant_kind == StructKind::Tuple {
mark::hit!(inserts_parens_for_tuple_enums);
cov_mark::hit!(inserts_parens_for_tuple_enums);
let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len());
builder =
builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params);
@@ -103,13 +102,11 @@ impl<'a> EnumRender<'a> {
#[cfg(test)]
mod tests {
use test_utils::mark;
use crate::test_utils::check_edit;
#[test]
fn inserts_parens_for_tuple_enums() {
mark::check!(inserts_parens_for_tuple_enums);
cov_mark::check!(inserts_parens_for_tuple_enums);
check_edit(
"Some",
r#"

View File

@@ -3,7 +3,6 @@
use hir::{HasSource, HirDisplay, Type};
use ide_db::SymbolKind;
use syntax::ast::Fn;
use test_utils::mark;
use crate::{
item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit},
@@ -82,7 +81,7 @@ impl<'a> FunctionRender<'a> {
self.func.method_params(self.ctx.db()).unwrap_or_default()
} else {
if let Some(s) = ast_params.self_param() {
mark::hit!(parens_for_method_call_as_assoc_fn);
cov_mark::hit!(parens_for_method_call_as_assoc_fn);
params_pats.push(Some(s.to_string()));
}
self.func.assoc_fn_params(self.ctx.db())
@@ -114,8 +113,6 @@ impl<'a> FunctionRender<'a> {
#[cfg(test)]
mod tests {
use test_utils::mark;
use crate::{
test_utils::{check_edit, check_edit_with_config, TEST_CONFIG},
CompletionConfig,
@@ -123,7 +120,7 @@ mod tests {
#[test]
fn inserts_parens_for_function_calls() {
mark::check!(inserts_parens_for_function_calls);
cov_mark::check!(inserts_parens_for_function_calls);
check_edit(
"no_args",
r#"
@@ -191,7 +188,7 @@ fn bar(s: &S) {
#[test]
fn parens_for_method_call_as_assoc_fn() {
mark::check!(parens_for_method_call_as_assoc_fn);
cov_mark::check!(parens_for_method_call_as_assoc_fn);
check_edit(
"foo",
r#"
@@ -213,7 +210,7 @@ fn main() { S::foo(${1:&self})$0 }
#[test]
fn suppress_arg_snippets() {
mark::check!(suppress_arg_snippets);
cov_mark::check!(suppress_arg_snippets);
check_edit_with_config(
CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG },
"with_args",

View File

@@ -3,7 +3,6 @@
use hir::{Documentation, HasSource};
use ide_db::SymbolKind;
use syntax::display::macro_label;
use test_utils::mark;
use crate::{
item::{CompletionItem, CompletionKind, ImportEdit},
@@ -57,7 +56,7 @@ impl<'a> MacroRender<'a> {
}
None if needs_bang => builder.insert_text(self.banged_name()),
_ => {
mark::hit!(dont_insert_macro_call_parens_unncessary);
cov_mark::hit!(dont_insert_macro_call_parens_unncessary);
builder.insert_text(&self.name)
}
};
@@ -125,13 +124,11 @@ fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static s
#[cfg(test)]
mod tests {
use test_utils::mark;
use crate::test_utils::check_edit;
#[test]
fn dont_insert_macro_call_parens_unncessary() {
mark::check!(dont_insert_macro_call_parens_unncessary);
cov_mark::check!(dont_insert_macro_call_parens_unncessary);
check_edit(
"frobnicate!",
r#"