Get rid of MockAnalysis
This commit is contained in:
parent
eeb27f95f1
commit
09348b2474
@ -117,13 +117,13 @@ fn test_crate(&self) -> CrateId {
|
||||
impl<DB: SourceDatabaseExt + Default + 'static> WithFixture for DB {}
|
||||
|
||||
pub struct ChangeFixture {
|
||||
file_position: Option<(FileId, RangeOrOffset)>,
|
||||
files: Vec<FileId>,
|
||||
change: Change,
|
||||
pub file_position: Option<(FileId, RangeOrOffset)>,
|
||||
pub files: Vec<FileId>,
|
||||
pub change: Change,
|
||||
}
|
||||
|
||||
impl ChangeFixture {
|
||||
fn parse(ra_fixture: &str) -> ChangeFixture {
|
||||
pub fn parse(ra_fixture: &str) -> ChangeFixture {
|
||||
let fixture = Fixture::parse(ra_fixture);
|
||||
let mut change = Change::new();
|
||||
|
||||
@ -132,6 +132,7 @@ fn parse(ra_fixture: &str) -> ChangeFixture {
|
||||
let mut crates = FxHashMap::default();
|
||||
let mut crate_deps = Vec::new();
|
||||
let mut default_crate_root: Option<FileId> = None;
|
||||
let mut default_cfg = CfgOptions::default();
|
||||
|
||||
let mut file_set = FileSet::default();
|
||||
let source_root_prefix = "/".to_string();
|
||||
@ -171,6 +172,7 @@ fn parse(ra_fixture: &str) -> ChangeFixture {
|
||||
} else if meta.path == "/main.rs" || meta.path == "/lib.rs" {
|
||||
assert!(default_crate_root.is_none());
|
||||
default_crate_root = Some(file_id);
|
||||
default_cfg = meta.cfg;
|
||||
}
|
||||
|
||||
change.change_file(file_id, Some(Arc::new(text)));
|
||||
@ -185,8 +187,8 @@ fn parse(ra_fixture: &str) -> ChangeFixture {
|
||||
crate_graph.add_crate_root(
|
||||
crate_root,
|
||||
Edition::Edition2018,
|
||||
None,
|
||||
CfgOptions::default(),
|
||||
Some("test".to_string()),
|
||||
default_cfg,
|
||||
Env::default(),
|
||||
Default::default(),
|
||||
);
|
||||
|
@ -181,8 +181,8 @@ fn caller() {
|
||||
call<|>ee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..14 3..9",
|
||||
&["caller FN FileId(1) 15..44 18..24 : [33..39]"],
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..44 18..24 : [33..39]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -197,8 +197,8 @@ fn caller() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..14 3..9",
|
||||
&["caller FN FileId(1) 15..44 18..24 : [33..39]"],
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..44 18..24 : [33..39]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -214,8 +214,8 @@ fn caller() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..14 3..9",
|
||||
&["caller FN FileId(1) 15..58 18..24 : [33..39, 47..53]"],
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..58 18..24 : [33..39, 47..53]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -234,10 +234,10 @@ fn caller2() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..14 3..9",
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&[
|
||||
"caller1 FN FileId(1) 15..45 18..25 : [34..40]",
|
||||
"caller2 FN FileId(1) 47..77 50..57 : [66..72]",
|
||||
"caller1 FN FileId(0) 15..45 18..25 : [34..40]",
|
||||
"caller2 FN FileId(0) 47..77 50..57 : [66..72]",
|
||||
],
|
||||
&[],
|
||||
);
|
||||
@ -263,10 +263,10 @@ fn test_caller() {
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..14 3..9",
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&[
|
||||
"caller1 FN FileId(1) 15..45 18..25 : [34..40]",
|
||||
"test_caller FN FileId(1) 95..149 110..121 : [134..140]",
|
||||
"caller1 FN FileId(0) 15..45 18..25 : [34..40]",
|
||||
"test_caller FN FileId(0) 95..149 110..121 : [134..140]",
|
||||
],
|
||||
&[],
|
||||
);
|
||||
@ -287,8 +287,8 @@ fn caller() {
|
||||
//- /foo/mod.rs
|
||||
pub fn callee() {}
|
||||
"#,
|
||||
"callee FN FileId(2) 0..18 7..13",
|
||||
&["caller FN FileId(1) 27..56 30..36 : [45..51]"],
|
||||
"callee FN FileId(1) 0..18 7..13",
|
||||
&["caller FN FileId(0) 27..56 30..36 : [45..51]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -304,9 +304,9 @@ fn call<|>er() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"caller FN FileId(1) 15..58 18..24",
|
||||
"caller FN FileId(0) 15..58 18..24",
|
||||
&[],
|
||||
&["callee FN FileId(1) 0..14 3..9 : [33..39, 47..53]"],
|
||||
&["callee FN FileId(0) 0..14 3..9 : [33..39, 47..53]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -325,9 +325,9 @@ fn call<|>er() {
|
||||
//- /foo/mod.rs
|
||||
pub fn callee() {}
|
||||
"#,
|
||||
"caller FN FileId(1) 27..56 30..36",
|
||||
"caller FN FileId(0) 27..56 30..36",
|
||||
&[],
|
||||
&["callee FN FileId(2) 0..18 7..13 : [45..51]"],
|
||||
&["callee FN FileId(1) 0..18 7..13 : [45..51]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -348,9 +348,9 @@ fn caller3() {
|
||||
|
||||
}
|
||||
"#,
|
||||
"caller2 FN FileId(1) 33..64 36..43",
|
||||
&["caller1 FN FileId(1) 0..31 3..10 : [19..26]"],
|
||||
&["caller3 FN FileId(1) 66..83 69..76 : [52..59]"],
|
||||
"caller2 FN FileId(0) 33..64 36..43",
|
||||
&["caller1 FN FileId(0) 0..31 3..10 : [19..26]"],
|
||||
&["caller3 FN FileId(0) 66..83 69..76 : [52..59]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -368,9 +368,9 @@ fn main() {
|
||||
a<|>()
|
||||
}
|
||||
"#,
|
||||
"a FN FileId(1) 0..18 3..4",
|
||||
&["main FN FileId(1) 31..52 34..38 : [47..48]"],
|
||||
&["b FN FileId(1) 20..29 23..24 : [13..14]"],
|
||||
"a FN FileId(0) 0..18 3..4",
|
||||
&["main FN FileId(0) 31..52 34..38 : [47..48]"],
|
||||
&["b FN FileId(0) 20..29 23..24 : [13..14]"],
|
||||
);
|
||||
|
||||
check_hierarchy(
|
||||
@ -385,8 +385,8 @@ fn main() {
|
||||
a()
|
||||
}
|
||||
"#,
|
||||
"b FN FileId(1) 20..29 23..24",
|
||||
&["a FN FileId(1) 0..18 3..4 : [13..14]"],
|
||||
"b FN FileId(0) 20..29 23..24",
|
||||
&["a FN FileId(0) 0..18 3..4 : [13..14]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
|
@ -495,13 +495,13 @@ fn test() {
|
||||
fn test_completion_await_impls_future() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
use std::future::*;
|
||||
struct A {}
|
||||
impl Future for A {}
|
||||
fn foo(a: A) { a.<|> }
|
||||
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
pub mod future {
|
||||
#[lang = "future_trait"]
|
||||
pub trait Future {}
|
||||
@ -514,14 +514,14 @@ pub trait Future {}
|
||||
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
use std::future::*;
|
||||
fn foo() {
|
||||
let a = async {};
|
||||
a.<|>
|
||||
}
|
||||
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
pub mod future {
|
||||
#[lang = "future_trait"]
|
||||
pub trait Future {
|
||||
|
@ -300,7 +300,7 @@ fn baz() {}
|
||||
// "#,
|
||||
// expect![[r#"
|
||||
// md bar;
|
||||
// "#]],
|
||||
// "#]],foo
|
||||
// );
|
||||
// }
|
||||
|
||||
@ -308,7 +308,7 @@ fn baz() {}
|
||||
fn already_declared_bin_module_completion_omitted() {
|
||||
check(
|
||||
r#"
|
||||
//- /src/bin.rs
|
||||
//- /src/bin.rs crate:main
|
||||
fn main() {}
|
||||
//- /src/bin/foo.rs
|
||||
mod <|>
|
||||
|
@ -422,10 +422,10 @@ fn m() fn m()
|
||||
fn completes_use_paths_across_crates() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:foo
|
||||
use foo::<|>;
|
||||
|
||||
//- /foo/lib.rs
|
||||
//- /foo/lib.rs crate:foo
|
||||
pub mod bar { pub struct S; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -271,10 +271,10 @@ fn quux() fn quux()
|
||||
fn completes_extern_prelude() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
//- /lib.rs crate:main deps:other_crate
|
||||
use <|>;
|
||||
|
||||
//- /other_crate/lib.rs
|
||||
//- /other_crate/lib.rs crate:other_crate
|
||||
// nothing here
|
||||
"#,
|
||||
expect![[r#"
|
||||
@ -350,10 +350,10 @@ fn completes_self_in_methods() {
|
||||
fn completes_prelude() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
fn foo() { let x: <|> }
|
||||
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
#[prelude_import]
|
||||
use prelude::*;
|
||||
|
||||
@ -371,16 +371,16 @@ fn foo() fn foo()
|
||||
fn completes_std_prelude_if_core_is_defined() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core,std
|
||||
fn foo() { let x: <|> }
|
||||
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
#[prelude_import]
|
||||
use prelude::*;
|
||||
|
||||
mod prelude { struct Option; }
|
||||
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std deps:core
|
||||
#[prelude_import]
|
||||
use prelude::*;
|
||||
|
||||
|
@ -1172,9 +1172,9 @@ fn dont_insert_macro_call_parens_unncessary() {
|
||||
check_edit(
|
||||
"frobnicate!",
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:foo
|
||||
use foo::<|>;
|
||||
//- /foo/lib.rs
|
||||
//- /foo/lib.rs crate:foo
|
||||
#[macro_export]
|
||||
macro_rules frobnicate { () => () }
|
||||
"#,
|
||||
|
@ -219,7 +219,7 @@ mod tests {
|
||||
use test_utils::assert_eq_text;
|
||||
|
||||
use crate::{
|
||||
mock_analysis::{analysis_and_position, single_file, MockAnalysis},
|
||||
mock_analysis::{analysis_and_position, many_files, single_file},
|
||||
DiagnosticsConfig,
|
||||
};
|
||||
|
||||
@ -282,9 +282,7 @@ fn check_apply_diagnostic_fix_in_other_file(ra_fixture_before: &str, ra_fixture_
|
||||
/// 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_diagnostics(ra_fixture: &str) {
|
||||
let mock = MockAnalysis::with_files(ra_fixture);
|
||||
let files = mock.files().map(|(it, _)| it).collect::<Vec<_>>();
|
||||
let analysis = mock.analysis();
|
||||
let (analysis, files) = many_files(ra_fixture);
|
||||
let diagnostics = files
|
||||
.into_iter()
|
||||
.flat_map(|file_id| {
|
||||
@ -304,7 +302,7 @@ fn check_expect(ra_fixture: &str, expect: Expect) {
|
||||
fn test_wrap_return_type() {
|
||||
check_fix(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
||||
fn div(x: i32, y: i32) -> Result<i32, ()> {
|
||||
@ -313,7 +311,7 @@ fn div(x: i32, y: i32) -> Result<i32, ()> {
|
||||
}
|
||||
x / y<|>
|
||||
}
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
pub mod result {
|
||||
pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
}
|
||||
@ -335,7 +333,7 @@ fn div(x: i32, y: i32) -> Result<i32, ()> {
|
||||
fn test_wrap_return_type_handles_generic_functions() {
|
||||
check_fix(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
||||
fn div<T>(x: T) -> Result<T, i32> {
|
||||
@ -344,7 +342,7 @@ fn div<T>(x: T) -> Result<T, i32> {
|
||||
}
|
||||
<|>x
|
||||
}
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
pub mod result {
|
||||
pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
}
|
||||
@ -366,7 +364,7 @@ fn div<T>(x: T) -> Result<T, i32> {
|
||||
fn test_wrap_return_type_handles_type_aliases() {
|
||||
check_fix(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
||||
type MyResult<T> = Result<T, ()>;
|
||||
@ -377,7 +375,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
|
||||
}
|
||||
x <|>/ y
|
||||
}
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
pub mod result {
|
||||
pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
}
|
||||
@ -401,12 +399,12 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
|
||||
fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
|
||||
check_no_diagnostics(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
||||
fn foo() -> Result<(), i32> { 0 }
|
||||
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
pub mod result {
|
||||
pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
}
|
||||
@ -418,14 +416,14 @@ pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() {
|
||||
check_no_diagnostics(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:core
|
||||
use core::result::Result::{self, Ok, Err};
|
||||
|
||||
enum SomeOtherEnum { Ok(i32), Err(String) }
|
||||
|
||||
fn foo() -> SomeOtherEnum { 0 }
|
||||
|
||||
//- /core/lib.rs
|
||||
//- /core/lib.rs crate:core
|
||||
pub mod result {
|
||||
pub enum Result<T, E> { Ok(T), Err(E) }
|
||||
}
|
||||
@ -567,7 +565,7 @@ fn test_unresolved_module_diagnostic() {
|
||||
file_system_edits: [
|
||||
CreateFile {
|
||||
anchor: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
dst: "foo.rs",
|
||||
},
|
||||
|
@ -439,7 +439,7 @@ fn foo() { enum FooInner { } }
|
||||
[
|
||||
NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..17,
|
||||
focus_range: Some(
|
||||
@ -455,7 +455,7 @@ fn foo() { enum FooInner { } }
|
||||
},
|
||||
NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 29..46,
|
||||
focus_range: Some(
|
||||
|
@ -103,12 +103,11 @@ mod tests {
|
||||
use base_db::FileRange;
|
||||
use syntax::{TextRange, TextSize};
|
||||
|
||||
use crate::mock_analysis::MockAnalysis;
|
||||
use crate::mock_analysis::analysis_and_annotations;
|
||||
|
||||
fn check(ra_fixture: &str) {
|
||||
let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture);
|
||||
let (mut expected, data) = mock.annotation();
|
||||
let analysis = mock.analysis();
|
||||
let (analysis, position, mut annotations) = analysis_and_annotations(ra_fixture);
|
||||
let (mut expected, data) = annotations.pop().unwrap();
|
||||
match data.as_str() {
|
||||
"" => (),
|
||||
"file" => {
|
||||
@ -133,9 +132,9 @@ fn check(ra_fixture: &str) {
|
||||
fn goto_def_for_extern_crate() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
extern crate std<|>;
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
// empty
|
||||
//^ file
|
||||
"#,
|
||||
@ -146,9 +145,9 @@ fn goto_def_for_extern_crate() {
|
||||
fn goto_def_for_renamed_extern_crate() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
extern crate std as abc<|>;
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
// empty
|
||||
//^ file
|
||||
"#,
|
||||
@ -342,10 +341,10 @@ fn bar() {
|
||||
fn goto_def_for_use_alias() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
//- /lib.rs crate:main deps:foo
|
||||
use foo as bar<|>;
|
||||
|
||||
//- /foo/lib.rs
|
||||
//- /foo/lib.rs crate:foo
|
||||
// empty
|
||||
//^ file
|
||||
"#,
|
||||
@ -356,10 +355,10 @@ fn goto_def_for_use_alias() {
|
||||
fn goto_def_for_use_alias_foo_macro() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
//- /lib.rs crate:main deps:foo
|
||||
use foo::foo as bar<|>;
|
||||
|
||||
//- /foo/lib.rs
|
||||
//- /foo/lib.rs crate:foo
|
||||
#[macro_export]
|
||||
macro_rules! foo { () => { () } }
|
||||
//^^^
|
||||
@ -371,7 +370,6 @@ macro_rules! foo { () => { () } }
|
||||
fn goto_def_for_methods() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
fn frobnicate(&self) { }
|
||||
|
@ -76,12 +76,10 @@ fn impls_for_trait(
|
||||
mod tests {
|
||||
use base_db::FileRange;
|
||||
|
||||
use crate::mock_analysis::MockAnalysis;
|
||||
use crate::mock_analysis::analysis_and_annotations;
|
||||
|
||||
fn check(ra_fixture: &str) {
|
||||
let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture);
|
||||
let annotations = mock.annotations();
|
||||
let analysis = mock.analysis();
|
||||
let (analysis, position, annotations) = analysis_and_annotations(ra_fixture);
|
||||
|
||||
let navs = analysis.goto_implementation(position).unwrap().unwrap().info;
|
||||
|
||||
|
@ -56,13 +56,12 @@ fn priority(n: &SyntaxToken) -> usize {
|
||||
mod tests {
|
||||
use base_db::FileRange;
|
||||
|
||||
use crate::mock_analysis::MockAnalysis;
|
||||
use crate::mock_analysis::analysis_and_annotations;
|
||||
|
||||
fn check(ra_fixture: &str) {
|
||||
let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture);
|
||||
let (expected, data) = mock.annotation();
|
||||
let (analysis, position, mut annotations) = analysis_and_annotations(ra_fixture);
|
||||
let (expected, data) = annotations.pop().unwrap();
|
||||
assert!(data.is_empty());
|
||||
let analysis = mock.analysis();
|
||||
|
||||
let mut navs = analysis.goto_type_definition(position).unwrap().unwrap().info;
|
||||
assert_eq!(navs.len(), 1);
|
||||
|
@ -1275,7 +1275,7 @@ fn test_hover_trait_show_qualifiers() {
|
||||
Implementaion(
|
||||
FilePosition {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
offset: 13,
|
||||
},
|
||||
@ -1289,9 +1289,9 @@ fn test_hover_trait_show_qualifiers() {
|
||||
fn test_hover_extern_crate() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
extern crate st<|>d;
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
//! Standard library for this test
|
||||
//!
|
||||
//! Printed?
|
||||
@ -1307,9 +1307,9 @@ fn test_hover_extern_crate() {
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std
|
||||
extern crate std as ab<|>c;
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
//! Standard library for this test
|
||||
//!
|
||||
//! Printed?
|
||||
@ -1989,7 +1989,7 @@ fn test_hover_trait_has_impl_action() {
|
||||
Implementaion(
|
||||
FilePosition {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
offset: 6,
|
||||
},
|
||||
@ -2008,7 +2008,7 @@ fn test_hover_struct_has_impl_action() {
|
||||
Implementaion(
|
||||
FilePosition {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
offset: 7,
|
||||
},
|
||||
@ -2027,7 +2027,7 @@ fn test_hover_union_has_impl_action() {
|
||||
Implementaion(
|
||||
FilePosition {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
offset: 6,
|
||||
},
|
||||
@ -2046,7 +2046,7 @@ fn test_hover_enum_has_impl_action() {
|
||||
Implementaion(
|
||||
FilePosition {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
offset: 5,
|
||||
},
|
||||
@ -2069,7 +2069,7 @@ fn foo_<|>test() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..24,
|
||||
focus_range: Some(
|
||||
@ -2112,7 +2112,7 @@ fn foo_test() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..46,
|
||||
focus_range: Some(
|
||||
@ -2151,7 +2151,7 @@ struct S{ f1: u32 }
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..19,
|
||||
focus_range: Some(
|
||||
@ -2190,7 +2190,7 @@ struct S<T>{ f1: T }
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 17..37,
|
||||
focus_range: Some(
|
||||
@ -2209,7 +2209,7 @@ struct S<T>{ f1: T }
|
||||
mod_path: "test::Arg",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..16,
|
||||
focus_range: Some(
|
||||
@ -2248,7 +2248,7 @@ struct S<T>{ f1: T }
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 17..37,
|
||||
focus_range: Some(
|
||||
@ -2267,7 +2267,7 @@ struct S<T>{ f1: T }
|
||||
mod_path: "test::Arg",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..16,
|
||||
focus_range: Some(
|
||||
@ -2309,7 +2309,7 @@ mod M {
|
||||
mod_path: "test::A",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..14,
|
||||
focus_range: Some(
|
||||
@ -2328,7 +2328,7 @@ mod M {
|
||||
mod_path: "test::B",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 15..29,
|
||||
focus_range: Some(
|
||||
@ -2347,7 +2347,7 @@ mod M {
|
||||
mod_path: "test::M::C",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 42..60,
|
||||
focus_range: Some(
|
||||
@ -2386,7 +2386,7 @@ fn foo() -> impl Foo {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2426,7 +2426,7 @@ fn foo() -> impl Foo<S> {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..15,
|
||||
focus_range: Some(
|
||||
@ -2445,7 +2445,7 @@ fn foo() -> impl Foo<S> {}
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 16..25,
|
||||
focus_range: Some(
|
||||
@ -2485,7 +2485,7 @@ fn foo() -> impl Foo + Bar {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2504,7 +2504,7 @@ fn foo() -> impl Foo + Bar {}
|
||||
mod_path: "test::Bar",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 13..25,
|
||||
focus_range: Some(
|
||||
@ -2547,7 +2547,7 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..15,
|
||||
focus_range: Some(
|
||||
@ -2566,7 +2566,7 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
|
||||
mod_path: "test::Bar",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 16..31,
|
||||
focus_range: Some(
|
||||
@ -2585,7 +2585,7 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
|
||||
mod_path: "test::S1",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 32..44,
|
||||
focus_range: Some(
|
||||
@ -2604,7 +2604,7 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
|
||||
mod_path: "test::S2",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 45..57,
|
||||
focus_range: Some(
|
||||
@ -2641,7 +2641,7 @@ fn foo(ar<|>g: &impl Foo) {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2681,7 +2681,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2700,7 +2700,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
mod_path: "test::Bar",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 13..28,
|
||||
focus_range: Some(
|
||||
@ -2719,7 +2719,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 29..39,
|
||||
focus_range: Some(
|
||||
@ -2764,7 +2764,7 @@ mod future {
|
||||
mod_path: "test::future::Future",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 101..163,
|
||||
focus_range: Some(
|
||||
@ -2783,7 +2783,7 @@ mod future {
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..9,
|
||||
focus_range: Some(
|
||||
@ -2821,7 +2821,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..15,
|
||||
focus_range: Some(
|
||||
@ -2840,7 +2840,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 16..27,
|
||||
focus_range: Some(
|
||||
@ -2883,7 +2883,7 @@ fn foo() -> B<dyn Foo> {}
|
||||
mod_path: "test::B",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 42..55,
|
||||
focus_range: Some(
|
||||
@ -2902,7 +2902,7 @@ fn foo() -> B<dyn Foo> {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2939,7 +2939,7 @@ fn foo(ar<|>g: &dyn Foo) {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..12,
|
||||
focus_range: Some(
|
||||
@ -2977,7 +2977,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..15,
|
||||
focus_range: Some(
|
||||
@ -2996,7 +2996,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 16..27,
|
||||
focus_range: Some(
|
||||
@ -3037,7 +3037,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
mod_path: "test::ImplTrait",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..21,
|
||||
focus_range: Some(
|
||||
@ -3056,7 +3056,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
mod_path: "test::B",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 43..57,
|
||||
focus_range: Some(
|
||||
@ -3075,7 +3075,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
mod_path: "test::DynTrait",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 22..42,
|
||||
focus_range: Some(
|
||||
@ -3094,7 +3094,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
mod_path: "test::S",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 58..69,
|
||||
focus_range: Some(
|
||||
@ -3142,7 +3142,7 @@ fn test() -> impl Foo { S {} }
|
||||
mod_path: "test::Foo",
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 0..62,
|
||||
focus_range: Some(
|
||||
|
@ -1,174 +1,73 @@
|
||||
//! FIXME: write short doc here
|
||||
use std::sync::Arc;
|
||||
|
||||
use base_db::{CrateName, FileSet, SourceRoot, VfsPath};
|
||||
use cfg::CfgOptions;
|
||||
use test_utils::{
|
||||
extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER,
|
||||
};
|
||||
use base_db::fixture::ChangeFixture;
|
||||
use test_utils::{extract_annotations, RangeOrOffset};
|
||||
|
||||
use crate::{Analysis, AnalysisHost, Change, CrateGraph, Edition, FileId, FilePosition, FileRange};
|
||||
|
||||
/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
|
||||
/// from a set of in-memory files.
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct MockAnalysis {
|
||||
files: Vec<Fixture>,
|
||||
}
|
||||
|
||||
impl MockAnalysis {
|
||||
/// Creates `MockAnalysis` using a fixture data in the following format:
|
||||
///
|
||||
/// ```not_rust
|
||||
/// //- /main.rs
|
||||
/// mod foo;
|
||||
/// fn main() {}
|
||||
///
|
||||
/// //- /foo.rs
|
||||
/// struct Baz;
|
||||
/// ```
|
||||
pub(crate) fn with_files(ra_fixture: &str) -> MockAnalysis {
|
||||
let (res, pos) = MockAnalysis::with_fixture(ra_fixture);
|
||||
assert!(pos.is_none());
|
||||
res
|
||||
}
|
||||
|
||||
/// Same as `with_files`, but requires that a single file contains a `<|>` marker,
|
||||
/// whose position is also returned.
|
||||
pub(crate) fn with_files_and_position(fixture: &str) -> (MockAnalysis, FilePosition) {
|
||||
let (res, position) = MockAnalysis::with_fixture(fixture);
|
||||
let (file_id, range_or_offset) = position.expect("expected a marker (<|>)");
|
||||
let offset = match range_or_offset {
|
||||
RangeOrOffset::Range(_) => panic!(),
|
||||
RangeOrOffset::Offset(it) => it,
|
||||
};
|
||||
(res, FilePosition { file_id, offset })
|
||||
}
|
||||
|
||||
fn with_fixture(fixture: &str) -> (MockAnalysis, Option<(FileId, RangeOrOffset)>) {
|
||||
let mut position = None;
|
||||
let mut res = MockAnalysis::default();
|
||||
for mut entry in Fixture::parse(fixture) {
|
||||
if entry.text.contains(CURSOR_MARKER) {
|
||||
assert!(position.is_none(), "only one marker (<|>) per fixture is allowed");
|
||||
let (range_or_offset, text) = extract_range_or_offset(&entry.text);
|
||||
entry.text = text;
|
||||
let file_id = res.add_file_fixture(entry);
|
||||
position = Some((file_id, range_or_offset));
|
||||
} else {
|
||||
res.add_file_fixture(entry);
|
||||
}
|
||||
}
|
||||
(res, position)
|
||||
}
|
||||
|
||||
fn add_file_fixture(&mut self, fixture: Fixture) -> FileId {
|
||||
let file_id = FileId((self.files.len() + 1) as u32);
|
||||
self.files.push(fixture);
|
||||
file_id
|
||||
}
|
||||
|
||||
pub(crate) fn id_of(&self, path: &str) -> FileId {
|
||||
let (file_id, _) =
|
||||
self.files().find(|(_, data)| path == data.path).expect("no file in this mock");
|
||||
file_id
|
||||
}
|
||||
pub(crate) fn annotations(&self) -> Vec<(FileRange, String)> {
|
||||
self.files()
|
||||
.flat_map(|(file_id, fixture)| {
|
||||
let annotations = extract_annotations(&fixture.text);
|
||||
annotations
|
||||
.into_iter()
|
||||
.map(move |(range, data)| (FileRange { file_id, range }, data))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
pub(crate) fn files(&self) -> impl Iterator<Item = (FileId, &Fixture)> + '_ {
|
||||
self.files.iter().enumerate().map(|(idx, fixture)| (FileId(idx as u32 + 1), fixture))
|
||||
}
|
||||
pub(crate) fn annotation(&self) -> (FileRange, String) {
|
||||
let mut all = self.annotations();
|
||||
assert_eq!(all.len(), 1);
|
||||
all.pop().unwrap()
|
||||
}
|
||||
pub(crate) fn analysis_host(self) -> AnalysisHost {
|
||||
let mut host = AnalysisHost::default();
|
||||
let mut change = Change::new();
|
||||
let mut file_set = FileSet::default();
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
let mut root_crate = None;
|
||||
for (i, data) in self.files.into_iter().enumerate() {
|
||||
let path = data.path;
|
||||
assert!(path.starts_with('/'));
|
||||
|
||||
let mut cfg = CfgOptions::default();
|
||||
data.cfg_atoms.iter().for_each(|it| cfg.insert_atom(it.into()));
|
||||
data.cfg_key_values.iter().for_each(|(k, v)| cfg.insert_key_value(k.into(), v.into()));
|
||||
let edition: Edition =
|
||||
data.edition.and_then(|it| it.parse().ok()).unwrap_or(Edition::Edition2018);
|
||||
|
||||
let file_id = FileId(i as u32 + 1);
|
||||
let env = data.env.into_iter().collect();
|
||||
if path == "/lib.rs" || path == "/main.rs" {
|
||||
root_crate = Some(crate_graph.add_crate_root(
|
||||
file_id,
|
||||
edition,
|
||||
Some("test".to_string()),
|
||||
cfg,
|
||||
env,
|
||||
Default::default(),
|
||||
));
|
||||
} else if path.ends_with("/lib.rs") {
|
||||
let base = &path[..path.len() - "/lib.rs".len()];
|
||||
let crate_name = &base[base.rfind('/').unwrap() + '/'.len_utf8()..];
|
||||
let other_crate = crate_graph.add_crate_root(
|
||||
file_id,
|
||||
edition,
|
||||
Some(crate_name.to_string()),
|
||||
cfg,
|
||||
env,
|
||||
Default::default(),
|
||||
);
|
||||
if let Some(root_crate) = root_crate {
|
||||
crate_graph
|
||||
.add_dep(root_crate, CrateName::new(crate_name).unwrap(), other_crate)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
let path = VfsPath::new_virtual_path(path.to_string());
|
||||
file_set.insert(file_id, path);
|
||||
change.change_file(file_id, Some(Arc::new(data.text).to_owned()));
|
||||
}
|
||||
change.set_crate_graph(crate_graph);
|
||||
change.set_roots(vec![SourceRoot::new_local(file_set)]);
|
||||
host.apply_change(change);
|
||||
host
|
||||
}
|
||||
pub(crate) fn analysis(self) -> Analysis {
|
||||
self.analysis_host().analysis()
|
||||
}
|
||||
}
|
||||
use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange};
|
||||
|
||||
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
|
||||
pub(crate) fn analysis_and_position(ra_fixture: &str) -> (Analysis, FilePosition) {
|
||||
let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture);
|
||||
(mock.analysis(), position)
|
||||
let mut host = AnalysisHost::default();
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
host.db.apply_change(change_fixture.change);
|
||||
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)");
|
||||
let offset = match range_or_offset {
|
||||
RangeOrOffset::Range(_) => panic!(),
|
||||
RangeOrOffset::Offset(it) => it,
|
||||
};
|
||||
(host.analysis(), FilePosition { file_id, offset })
|
||||
}
|
||||
|
||||
/// Creates analysis for a single file.
|
||||
pub(crate) fn single_file(ra_fixture: &str) -> (Analysis, FileId) {
|
||||
let mock = MockAnalysis::with_files(ra_fixture);
|
||||
let file_id = mock.id_of("/main.rs");
|
||||
(mock.analysis(), file_id)
|
||||
let mut host = AnalysisHost::default();
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
host.db.apply_change(change_fixture.change);
|
||||
(host.analysis(), change_fixture.files[0])
|
||||
}
|
||||
|
||||
/// Creates analysis for a single file.
|
||||
pub(crate) fn many_files(ra_fixture: &str) -> (Analysis, Vec<FileId>) {
|
||||
let mut host = AnalysisHost::default();
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
host.db.apply_change(change_fixture.change);
|
||||
(host.analysis(), change_fixture.files)
|
||||
}
|
||||
|
||||
/// Creates analysis for a single file, returns range marked with a pair of <|>.
|
||||
pub(crate) fn analysis_and_range(ra_fixture: &str) -> (Analysis, FileRange) {
|
||||
let (res, position) = MockAnalysis::with_fixture(ra_fixture);
|
||||
let (file_id, range_or_offset) = position.expect("expected a marker (<|>)");
|
||||
let mut host = AnalysisHost::default();
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
host.db.apply_change(change_fixture.change);
|
||||
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)");
|
||||
let range = match range_or_offset {
|
||||
RangeOrOffset::Range(it) => it,
|
||||
RangeOrOffset::Offset(_) => panic!(),
|
||||
};
|
||||
(res.analysis(), FileRange { file_id, range })
|
||||
(host.analysis(), FileRange { file_id, range })
|
||||
}
|
||||
|
||||
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
|
||||
pub(crate) fn analysis_and_annotations(
|
||||
ra_fixture: &str,
|
||||
) -> (Analysis, FilePosition, Vec<(FileRange, String)>) {
|
||||
let mut host = AnalysisHost::default();
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
host.db.apply_change(change_fixture.change);
|
||||
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)");
|
||||
let offset = match range_or_offset {
|
||||
RangeOrOffset::Range(_) => panic!(),
|
||||
RangeOrOffset::Offset(it) => it,
|
||||
};
|
||||
|
||||
let annotations = change_fixture
|
||||
.files
|
||||
.iter()
|
||||
.flat_map(|&file_id| {
|
||||
let file_text = host.analysis().file_text(file_id).unwrap();
|
||||
let annotations = extract_annotations(&file_text);
|
||||
annotations.into_iter().map(move |(range, data)| (FileRange { file_id, range }, data))
|
||||
})
|
||||
.collect();
|
||||
(host.analysis(), FilePosition { file_id, offset }, annotations)
|
||||
}
|
||||
|
@ -63,15 +63,9 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use base_db::Env;
|
||||
use cfg::CfgOptions;
|
||||
use test_utils::mark;
|
||||
|
||||
use crate::{
|
||||
mock_analysis::{analysis_and_position, MockAnalysis},
|
||||
Change, CrateGraph,
|
||||
Edition::Edition2018,
|
||||
};
|
||||
use crate::mock_analysis::{analysis_and_position, single_file};
|
||||
|
||||
#[test]
|
||||
fn test_resolve_parent_module() {
|
||||
@ -84,7 +78,7 @@ fn test_resolve_parent_module() {
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("foo MODULE FileId(1) 0..8");
|
||||
nav.assert_match("foo MODULE FileId(0) 0..8");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -103,7 +97,7 @@ fn test_resolve_parent_module_on_module_decl() {
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("foo MODULE FileId(1) 0..8");
|
||||
nav.assert_match("foo MODULE FileId(0) 0..8");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -119,37 +113,19 @@ mod baz { <|> }
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("baz MODULE FileId(1) 32..44");
|
||||
nav.assert_match("baz MODULE FileId(0) 32..44");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_resolve_crate_root() {
|
||||
let mock = MockAnalysis::with_files(
|
||||
let (analysis, file_id) = single_file(
|
||||
r#"
|
||||
//- /bar.rs
|
||||
//- /main.rs
|
||||
mod foo;
|
||||
//- /foo.rs
|
||||
// empty
|
||||
<|>
|
||||
"#,
|
||||
);
|
||||
let root_file = mock.id_of("/bar.rs");
|
||||
let mod_file = mock.id_of("/foo.rs");
|
||||
let mut host = mock.analysis_host();
|
||||
assert!(host.analysis().crate_for(mod_file).unwrap().is_empty());
|
||||
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
let crate_id = crate_graph.add_crate_root(
|
||||
root_file,
|
||||
Edition2018,
|
||||
None,
|
||||
CfgOptions::default(),
|
||||
Env::default(),
|
||||
Default::default(),
|
||||
);
|
||||
let mut change = Change::new();
|
||||
change.set_crate_graph(crate_graph);
|
||||
host.apply_change(change);
|
||||
|
||||
assert_eq!(host.analysis().crate_for(mod_file).unwrap(), vec![crate_id]);
|
||||
assert_eq!(analysis.crate_for(file_id).unwrap().len(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -190,10 +190,11 @@ fn get_struct_def_name_for_struct_literal_search(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use base_db::FileId;
|
||||
use expect_test::{expect, Expect};
|
||||
use stdx::format_to;
|
||||
|
||||
use crate::{mock_analysis::MockAnalysis, SearchScope};
|
||||
use crate::{mock_analysis::analysis_and_position, SearchScope};
|
||||
|
||||
#[test]
|
||||
fn test_struct_literal_after_space() {
|
||||
@ -211,9 +212,9 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(1) 0..26 7..10 Other
|
||||
Foo STRUCT FileId(0) 0..26 7..10 Other
|
||||
|
||||
FileId(1) 101..104 StructLiteral
|
||||
FileId(0) 101..104 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -229,10 +230,10 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(1) 0..13 7..10 Other
|
||||
Foo STRUCT FileId(0) 0..13 7..10 Other
|
||||
|
||||
FileId(1) 41..44 Other
|
||||
FileId(1) 54..57 StructLiteral
|
||||
FileId(0) 41..44 Other
|
||||
FileId(0) 54..57 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -248,9 +249,9 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(1) 0..16 7..10 Other
|
||||
Foo STRUCT FileId(0) 0..16 7..10 Other
|
||||
|
||||
FileId(1) 64..67 StructLiteral
|
||||
FileId(0) 64..67 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -267,9 +268,9 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(1) 0..16 7..10 Other
|
||||
Foo STRUCT FileId(0) 0..16 7..10 Other
|
||||
|
||||
FileId(1) 54..57 StructLiteral
|
||||
FileId(0) 54..57 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -290,12 +291,12 @@ fn main() {
|
||||
i = 5;
|
||||
}"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(1) 24..25 Other Write
|
||||
i IDENT_PAT FileId(0) 24..25 Other Write
|
||||
|
||||
FileId(1) 50..51 Other Write
|
||||
FileId(1) 54..55 Other Read
|
||||
FileId(1) 76..77 Other Write
|
||||
FileId(1) 94..95 Other Write
|
||||
FileId(0) 50..51 Other Write
|
||||
FileId(0) 54..55 Other Read
|
||||
FileId(0) 76..77 Other Write
|
||||
FileId(0) 94..95 Other Write
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -314,10 +315,10 @@ fn bar() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
spam IDENT_PAT FileId(1) 19..23 Other
|
||||
spam IDENT_PAT FileId(0) 19..23 Other
|
||||
|
||||
FileId(1) 34..38 Other Read
|
||||
FileId(1) 41..45 Other Read
|
||||
FileId(0) 34..38 Other Read
|
||||
FileId(0) 41..45 Other Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -329,9 +330,9 @@ fn test_find_all_refs_for_param_inside() {
|
||||
fn foo(i : u32) -> u32 { i<|> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(1) 7..8 Other
|
||||
i IDENT_PAT FileId(0) 7..8 Other
|
||||
|
||||
FileId(1) 25..26 Other Read
|
||||
FileId(0) 25..26 Other Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -343,9 +344,9 @@ fn test_find_all_refs_for_fn_param() {
|
||||
fn foo(i<|> : u32) -> u32 { i }
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(1) 7..8 Other
|
||||
i IDENT_PAT FileId(0) 7..8 Other
|
||||
|
||||
FileId(1) 25..26 Other Read
|
||||
FileId(0) 25..26 Other Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -364,9 +365,9 @@ fn main(s: Foo) {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
spam RECORD_FIELD FileId(1) 17..30 21..25 Other
|
||||
spam RECORD_FIELD FileId(0) 17..30 21..25 Other
|
||||
|
||||
FileId(1) 67..71 Other Read
|
||||
FileId(0) 67..71 Other Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -381,7 +382,7 @@ fn f<|>(&self) { }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
f FN FileId(1) 27..43 30..31 Other
|
||||
f FN FileId(0) 27..43 30..31 Other
|
||||
|
||||
"#]],
|
||||
);
|
||||
@ -398,7 +399,7 @@ enum Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
B VARIANT FileId(1) 22..23 22..23 Other
|
||||
B VARIANT FileId(0) 22..23 22..23 Other
|
||||
|
||||
"#]],
|
||||
);
|
||||
@ -439,10 +440,10 @@ fn f() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(2) 17..51 28..31 Other
|
||||
Foo STRUCT FileId(1) 17..51 28..31 Other
|
||||
|
||||
FileId(1) 53..56 StructLiteral
|
||||
FileId(3) 79..82 StructLiteral
|
||||
FileId(0) 53..56 StructLiteral
|
||||
FileId(2) 79..82 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -469,9 +470,9 @@ pub struct Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
foo SOURCE_FILE FileId(2) 0..35 Other
|
||||
foo SOURCE_FILE FileId(1) 0..35 Other
|
||||
|
||||
FileId(1) 14..17 Other
|
||||
FileId(0) 14..17 Other
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -497,10 +498,10 @@ pub(super) struct Foo<|> {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(3) 0..41 18..21 Other
|
||||
Foo STRUCT FileId(2) 0..41 18..21 Other
|
||||
|
||||
FileId(2) 20..23 Other
|
||||
FileId(2) 47..50 StructLiteral
|
||||
FileId(1) 20..23 Other
|
||||
FileId(1) 47..50 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -525,20 +526,20 @@ pub fn quux<|>() {}
|
||||
code,
|
||||
None,
|
||||
expect![[r#"
|
||||
quux FN FileId(1) 19..35 26..30 Other
|
||||
quux FN FileId(0) 19..35 26..30 Other
|
||||
|
||||
FileId(1) 16..20 StructLiteral
|
||||
FileId(2) 16..20 StructLiteral
|
||||
FileId(3) 16..20 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
|
||||
check_with_scope(
|
||||
code,
|
||||
Some("/bar.rs"),
|
||||
Some(SearchScope::single_file(FileId(2))),
|
||||
expect![[r#"
|
||||
quux FN FileId(1) 19..35 26..30 Other
|
||||
quux FN FileId(0) 19..35 26..30 Other
|
||||
|
||||
FileId(3) 16..20 StructLiteral
|
||||
FileId(2) 16..20 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -556,10 +557,10 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
m1 MACRO_CALL FileId(1) 0..46 29..31 Other
|
||||
m1 MACRO_CALL FileId(0) 0..46 29..31 Other
|
||||
|
||||
FileId(1) 63..65 StructLiteral
|
||||
FileId(1) 73..75 StructLiteral
|
||||
FileId(0) 63..65 StructLiteral
|
||||
FileId(0) 73..75 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -574,10 +575,10 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(1) 23..24 Other Write
|
||||
i IDENT_PAT FileId(0) 23..24 Other Write
|
||||
|
||||
FileId(1) 34..35 Other Write
|
||||
FileId(1) 38..39 Other Read
|
||||
FileId(0) 34..35 Other Write
|
||||
FileId(0) 38..39 Other Read
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -596,10 +597,10 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
f RECORD_FIELD FileId(1) 15..21 15..16 Other
|
||||
f RECORD_FIELD FileId(0) 15..21 15..16 Other
|
||||
|
||||
FileId(1) 55..56 Other Read
|
||||
FileId(1) 68..69 Other Write
|
||||
FileId(0) 55..56 Other Read
|
||||
FileId(0) 68..69 Other Write
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -614,9 +615,9 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(1) 19..20 Other
|
||||
i IDENT_PAT FileId(0) 19..20 Other
|
||||
|
||||
FileId(1) 26..27 Other Write
|
||||
FileId(0) 26..27 Other Write
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -638,9 +639,9 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
new FN FileId(1) 54..81 61..64 Other
|
||||
new FN FileId(0) 54..81 61..64 Other
|
||||
|
||||
FileId(1) 126..129 StructLiteral
|
||||
FileId(0) 126..129 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -660,10 +661,10 @@ fn f<|>() {}
|
||||
fn g() { f(); }
|
||||
"#,
|
||||
expect![[r#"
|
||||
f FN FileId(1) 22..31 25..26 Other
|
||||
f FN FileId(0) 22..31 25..26 Other
|
||||
|
||||
FileId(2) 11..12 Other
|
||||
FileId(2) 24..25 StructLiteral
|
||||
FileId(1) 11..12 Other
|
||||
FileId(1) 24..25 StructLiteral
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
@ -672,11 +673,8 @@ fn check(ra_fixture: &str, expect: Expect) {
|
||||
check_with_scope(ra_fixture, None, expect)
|
||||
}
|
||||
|
||||
fn check_with_scope(ra_fixture: &str, search_scope: Option<&str>, expect: Expect) {
|
||||
let (mock_analysis, pos) = MockAnalysis::with_files_and_position(ra_fixture);
|
||||
let search_scope =
|
||||
search_scope.map(|path| SearchScope::single_file(mock_analysis.id_of(path)));
|
||||
let analysis = mock_analysis.analysis();
|
||||
fn check_with_scope(ra_fixture: &str, search_scope: Option<SearchScope>, expect: Expect) {
|
||||
let (analysis, pos) = analysis_and_position(ra_fixture);
|
||||
let refs = analysis.find_all_refs(pos, search_scope).unwrap().unwrap();
|
||||
|
||||
let mut actual = String::new();
|
||||
|
@ -602,7 +602,7 @@ fn test_rename_mod() {
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -617,10 +617,10 @@ fn test_rename_mod() {
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
anchor: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
dst: "foo2.rs",
|
||||
},
|
||||
@ -655,7 +655,7 @@ fn main() {}
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -668,7 +668,7 @@ fn main() {}
|
||||
},
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -683,10 +683,10 @@ fn main() {}
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
dst: "quux.rs",
|
||||
},
|
||||
@ -715,7 +715,7 @@ fn test_rename_mod_in_dir() {
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -730,10 +730,10 @@ fn test_rename_mod_in_dir() {
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
dst: "../foo2/mod.rs",
|
||||
},
|
||||
@ -763,7 +763,7 @@ fn test_rename_unusually_nested_mod() {
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -778,10 +778,10 @@ fn test_rename_unusually_nested_mod() {
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
dst: "bar.rs",
|
||||
},
|
||||
@ -834,7 +834,7 @@ fn f() {
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
2,
|
||||
1,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -847,7 +847,7 @@ fn f() {
|
||||
},
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
@ -862,10 +862,10 @@ fn f() {
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
anchor: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
dst: "foo2.rs",
|
||||
},
|
||||
|
@ -335,7 +335,7 @@ fn bench() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..13,
|
||||
focus_range: Some(
|
||||
@ -353,7 +353,7 @@ fn bench() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 15..39,
|
||||
focus_range: Some(
|
||||
@ -378,7 +378,7 @@ fn bench() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 41..75,
|
||||
focus_range: Some(
|
||||
@ -403,7 +403,7 @@ fn bench() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 77..99,
|
||||
focus_range: Some(
|
||||
@ -494,7 +494,7 @@ fn should_have_no_runnable_6() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..13,
|
||||
focus_range: Some(
|
||||
@ -512,7 +512,7 @@ fn should_have_no_runnable_6() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 15..74,
|
||||
focus_range: None,
|
||||
@ -532,7 +532,7 @@ fn should_have_no_runnable_6() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 76..148,
|
||||
focus_range: None,
|
||||
@ -552,7 +552,7 @@ fn should_have_no_runnable_6() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 150..254,
|
||||
focus_range: None,
|
||||
@ -596,7 +596,7 @@ fn foo() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..13,
|
||||
focus_range: Some(
|
||||
@ -614,7 +614,7 @@ fn foo() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 44..98,
|
||||
focus_range: None,
|
||||
@ -653,7 +653,7 @@ fn test_foo1() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..51,
|
||||
focus_range: Some(
|
||||
@ -673,7 +673,7 @@ fn test_foo1() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 20..49,
|
||||
focus_range: Some(
|
||||
@ -733,7 +733,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 22..323,
|
||||
focus_range: Some(
|
||||
@ -753,7 +753,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 51..192,
|
||||
focus_range: Some(
|
||||
@ -773,7 +773,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 84..126,
|
||||
focus_range: Some(
|
||||
@ -798,7 +798,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 140..182,
|
||||
focus_range: Some(
|
||||
@ -823,7 +823,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 202..286,
|
||||
focus_range: Some(
|
||||
@ -843,7 +843,7 @@ mod nested_tests_4 {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 235..276,
|
||||
focus_range: Some(
|
||||
@ -886,7 +886,7 @@ fn test_foo1() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..50,
|
||||
focus_range: Some(
|
||||
@ -934,7 +934,7 @@ fn test_foo1() {}
|
||||
Runnable {
|
||||
nav: NavigationTarget {
|
||||
file_id: FileId(
|
||||
1,
|
||||
0,
|
||||
),
|
||||
full_range: 1..72,
|
||||
focus_range: Some(
|
||||
|
@ -462,12 +462,12 @@ macro_rules! noop {
|
||||
fn test_extern_crate() {
|
||||
check_highlighting(
|
||||
r#"
|
||||
//- /main.rs
|
||||
//- /main.rs crate:main deps:std,alloc
|
||||
extern crate std;
|
||||
extern crate alloc as abc;
|
||||
//- /std/lib.rs
|
||||
//- /std/lib.rs crate:std
|
||||
pub struct S;
|
||||
//- /alloc/lib.rs
|
||||
//- /alloc/lib.rs crate:alloc
|
||||
pub struct A
|
||||
"#,
|
||||
expect_file!["./test_data/highlight_extern_crate.html"],
|
||||
|
Loading…
Reference in New Issue
Block a user