11442: fix(rename): Use text range of a mod name after macro expansion r=Veykril a=tysg Fixes #11417. 11460: fix: documentation of SsrParams r=Veykril a=nemethf Fix #11429 by extending the documentation of SsrParms with the mandatory field 'selections'. Copy its description from lsp_ext.rs. Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com> Co-authored-by: Felicián Németh <felician.nemeth@gmail.com>
This commit is contained in:
commit
59c49a9c81
|
@ -1133,6 +1133,34 @@ pub mod foo$0;
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rename_mod_in_macro() {
|
||||
check(
|
||||
"bar",
|
||||
r#"
|
||||
//- /foo.rs
|
||||
|
||||
//- /lib.rs
|
||||
macro_rules! submodule {
|
||||
($name:ident) => {
|
||||
mod $name;
|
||||
};
|
||||
}
|
||||
|
||||
submodule!($0foo);
|
||||
"#,
|
||||
r#"
|
||||
macro_rules! submodule {
|
||||
($name:ident) => {
|
||||
mod $name;
|
||||
};
|
||||
}
|
||||
|
||||
submodule!(bar);
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum_variant_from_module_1() {
|
||||
cov_mark::check!(rename_non_local);
|
||||
|
|
|
@ -188,16 +188,23 @@ fn rename_mod(
|
|||
source_change.push_file_system_edit(move_file);
|
||||
}
|
||||
|
||||
if let Some(InFile { file_id, value: decl_source }) = module.declaration_source(sema.db) {
|
||||
let file_id = file_id.original_file(sema.db);
|
||||
match decl_source.name() {
|
||||
Some(name) => source_change.insert_source_edit(
|
||||
file_id,
|
||||
TextEdit::replace(name.syntax().text_range(), new_name.to_string()),
|
||||
),
|
||||
if let Some(src) = module.declaration_source(sema.db) {
|
||||
let file_id = src.file_id.original_file(sema.db);
|
||||
match src.value.name() {
|
||||
Some(name) => {
|
||||
if let Some(file_range) =
|
||||
src.with_value(name.syntax()).original_file_range_opt(sema.db)
|
||||
{
|
||||
source_change.insert_source_edit(
|
||||
file_id,
|
||||
TextEdit::replace(file_range.range, new_name.to_string()),
|
||||
)
|
||||
};
|
||||
}
|
||||
_ => never!("Module source node is missing a name"),
|
||||
}
|
||||
}
|
||||
|
||||
let def = Definition::Module(module);
|
||||
let usages = def.usages(sema).all();
|
||||
let ref_edits = usages.iter().map(|(&file_id, references)| {
|
||||
|
|
|
@ -278,6 +278,8 @@ interface SsrParams {
|
|||
textDocument: TextDocumentIdentifier;
|
||||
/// Position where SSR was invoked.
|
||||
position: Position;
|
||||
/// Current selections. Search/replace will be restricted to these if non-empty.
|
||||
selections: Range[];
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue