Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/ra_ide/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ mod tests {
documentation: &'a str,
}

fn check_detail_and_documentation(fixture: &str, expected: DetailAndDocumentation) {
let (analysis, position) = analysis_and_position(fixture);
fn check_detail_and_documentation(ra_fixture: &str, expected: DetailAndDocumentation) {
let (analysis, position) = analysis_and_position(ra_fixture);
let config = CompletionConfig::default();
let completions = analysis.completions(&config, position).unwrap().unwrap();
for item in completions {
Expand Down
42 changes: 22 additions & 20 deletions crates/ra_ide/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ mod tests {
/// * a diagnostic is produced
/// * this diagnostic touches the input cursor position
/// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied
fn check_apply_diagnostic_fix_from_position(fixture: &str, after: &str) {
fn check_apply_diagnostic_fix_from_position(ra_fixture: &str, after: &str) {
let after = trim_indent(after);

let (analysis, file_position) = analysis_and_position(fixture);
let (analysis, file_position) = analysis_and_position(ra_fixture);
let diagnostic = analysis.diagnostics(file_position.file_id).unwrap().pop().unwrap();
let mut fix = diagnostic.fix.unwrap();
let edit = fix.source_change.source_file_edits.pop().unwrap().edit;
Expand Down Expand Up @@ -365,14 +365,14 @@ mod tests {

/// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
/// apply to the file containing the cursor.
fn check_no_diagnostic_for_target_file(fixture: &str) {
let (analysis, file_position) = analysis_and_position(fixture);
fn check_no_diagnostic_for_target_file(ra_fixture: &str) {
let (analysis, file_position) = analysis_and_position(ra_fixture);
let diagnostics = analysis.diagnostics(file_position.file_id).unwrap();
assert_eq!(diagnostics.len(), 0);
}

fn check_no_diagnostic(content: &str) {
let (analysis, file_id) = single_file(content);
fn check_no_diagnostic(ra_fixture: &str) {
let (analysis, file_id) = single_file(ra_fixture);
let diagnostics = analysis.diagnostics(file_id).unwrap();
assert_eq!(diagnostics.len(), 0, "expected no diagnostic, found one");
}
Expand Down Expand Up @@ -473,7 +473,8 @@ mod tests {

#[test]
fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
let content = r#"
check_no_diagnostic_for_target_file(
r"
//- /main.rs
use core::result::Result::{self, Ok, Err};

Expand All @@ -485,13 +486,14 @@ mod tests {
pub mod result {
pub enum Result<T, E> { Ok(T), Err(E) }
}
"#;
check_no_diagnostic_for_target_file(content);
",
);
}

#[test]
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() {
let content = r#"
check_no_diagnostic_for_target_file(
r"
//- /main.rs
use core::result::Result::{self, Ok, Err};

Expand All @@ -508,8 +510,8 @@ mod tests {
pub mod result {
pub enum Result<T, E> { Ok(T), Err(E) }
}
"#;
check_no_diagnostic_for_target_file(content);
",
);
}

#[test]
Expand Down Expand Up @@ -618,7 +620,8 @@ mod tests {

#[test]
fn test_fill_struct_fields_no_diagnostic() {
let content = r"
check_no_diagnostic(
r"
struct TestStruct {
one: i32,
two: i64,
Expand All @@ -628,14 +631,14 @@ mod tests {
let one = 1;
let s = TestStruct{ one, two: 2 };
}
";

check_no_diagnostic(content);
",
);
}

#[test]
fn test_fill_struct_fields_no_diagnostic_on_spread() {
let content = r"
check_no_diagnostic(
r"
struct TestStruct {
one: i32,
two: i64,
Expand All @@ -645,9 +648,8 @@ mod tests {
let one = 1;
let s = TestStruct{ ..a };
}
";

check_no_diagnostic(content);
",
);
}

#[test]
Expand Down
14 changes: 7 additions & 7 deletions crates/ra_ide/src/goto_type_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
mod tests {
use crate::mock_analysis::analysis_and_position;

fn check_goto(fixture: &str, expected: &str) {
let (analysis, pos) = analysis_and_position(fixture);
fn check_goto(ra_fixture: &str, expected: &str) {
let (analysis, pos) = analysis_and_position(ra_fixture);

let mut navs = analysis.goto_type_definition(pos).unwrap().unwrap().info;
assert_eq!(navs.len(), 1);
Expand All @@ -67,7 +67,7 @@ mod tests {
#[test]
fn goto_type_definition_works_simple() {
check_goto(
"
r"
//- /lib.rs
struct Foo;
fn foo() {
Expand All @@ -82,7 +82,7 @@ mod tests {
#[test]
fn goto_type_definition_works_simple_ref() {
check_goto(
"
r"
//- /lib.rs
struct Foo;
fn foo() {
Expand All @@ -97,7 +97,7 @@ mod tests {
#[test]
fn goto_type_definition_works_through_macro() {
check_goto(
"
r"
//- /lib.rs
macro_rules! id {
($($tt:tt)*) => { $($tt)* }
Expand All @@ -116,7 +116,7 @@ mod tests {
#[test]
fn goto_type_definition_for_param() {
check_goto(
"
r"
//- /lib.rs
struct Foo;
fn foo(<|>f: Foo) {}
Expand All @@ -128,7 +128,7 @@ mod tests {
#[test]
fn goto_type_definition_for_tuple_field() {
check_goto(
"
r"
//- /lib.rs
struct Foo;
struct Bar(Foo);
Expand Down
Loading