mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
use Source for module, part 1
This commit is contained in:
parent
178d8e96b5
commit
0145d06515
7 changed files with 23 additions and 27 deletions
|
@ -129,10 +129,10 @@ impl NavigationTarget {
|
|||
}
|
||||
|
||||
pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
|
||||
let (file_id, source) = module.definition_source(db);
|
||||
let file_id = file_id.as_original_file();
|
||||
let src = module.definition_source(db);
|
||||
let file_id = src.file_id.as_original_file();
|
||||
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
|
||||
match source {
|
||||
match src.ast {
|
||||
ModuleSource::SourceFile(node) => {
|
||||
NavigationTarget::from_syntax(file_id, name, None, node.syntax(), None, None)
|
||||
}
|
||||
|
|
|
@ -115,8 +115,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
|||
Some(Def(it)) => {
|
||||
match it {
|
||||
hir::ModuleDef::Module(it) => {
|
||||
let it = it.definition_source(db).1;
|
||||
if let hir::ModuleSource::Module(it) = it {
|
||||
if let hir::ModuleSource::Module(it) = it.definition_source(db).ast {
|
||||
res.extend(hover_text(it.doc_comment_text(), it.short_label()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,9 +148,9 @@ fn rename_mod(
|
|||
let mut file_system_edits = Vec::new();
|
||||
if let Some(module) = source_binder::module_from_declaration(db, position.file_id, &ast_module)
|
||||
{
|
||||
let (file_id, module_source) = module.definition_source(db);
|
||||
let file_id = file_id.as_original_file();
|
||||
match module_source {
|
||||
let src = module.definition_source(db);
|
||||
let file_id = src.file_id.as_original_file();
|
||||
match src.ast {
|
||||
ModuleSource::SourceFile(..) => {
|
||||
let mod_path: RelativePathBuf = db.file_relative_path(file_id);
|
||||
// mod is defined in path/to/dir/mod.rs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue