Merge #4175
4175: Introduce HirDisplay method for rendering source code & use it in add_function assist r=flodiebold a=TimoFreiberg Next feature for #3639. So far the only change in the new `HirDisplay` method is that paths are qualified, but more changes will be necessary (omitting the function name from function types, returning an error instead of printing `"{unknown}"`, probably more). Is that approach okay? Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
This commit is contained in:
23
crates/ra_hir_ty/src/tests/display_source_code.rs
Normal file
23
crates/ra_hir_ty/src/tests/display_source_code.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use super::displayed_source_at_pos;
|
||||
use crate::test_db::TestDB;
|
||||
use ra_db::fixture::WithFixture;
|
||||
|
||||
#[test]
|
||||
fn qualify_path_to_submodule() {
|
||||
let (db, pos) = TestDB::with_position(
|
||||
r#"
|
||||
//- /main.rs
|
||||
|
||||
mod foo {
|
||||
pub struct Foo;
|
||||
}
|
||||
|
||||
fn bar() {
|
||||
let foo: foo::Foo = foo::Foo;
|
||||
foo<|>
|
||||
}
|
||||
|
||||
"#,
|
||||
);
|
||||
assert_eq!("foo::Foo", displayed_source_at_pos(&db, pos));
|
||||
}
|
||||
Reference in New Issue
Block a user