3

fix(ide-db): correct single-file module rename by 00nktk · Pull Request #12387 ·...

 1 year ago
source link: https://github.com/rust-lang/rust-analyzer/pull/12387
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Member

lnicola commented 6 days ago

let is_mod_rs = module.is_mod_rs(sema.db);

let has_detached_child = module

.children(sema.db)

.any(|child| child.definition_source(sema.db).file_id != file_id);

This parses all those modules (not a big issue in this case really but its better to avoid parsing where possible), so it would be nice to avoid that. Could you add a function to hir::Module like is_outline, and similarly an is_outline function on ModuleOrigin to call, based on https://github.com/rust-lang/rust-analyzer/blob/master/crates/hir-def/src/nameres.rs#L171-L176

Contributor

Author

@00nktk 00nktk 5 days ago

Thanks for pointing it out. Couldn't figure it out myself that I'm literally checking if a child not inline. However, I felt that adding another function just for this case would be overkill (and I couldn't find any usage of the term "outline" in this context), so I just rewrote it with !child.is_inline(sema.db). Ping me if you still think otherwise and I'll rewrite it via is_outline function.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK