mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Turn ImplBlock into a copy type just containing IDs
This makes it more like the other code model types. Also make Module::definition_source/declaration_source return HirFileIds, to make them more like the other source functions.
This commit is contained in:
parent
6932b77093
commit
0242acae53
9 changed files with 65 additions and 77 deletions
|
@ -36,10 +36,10 @@ pub fn run(verbose: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for impl_block in module.impl_blocks(&db) {
|
for impl_block in module.impl_blocks(&db) {
|
||||||
for item in impl_block.items() {
|
for item in impl_block.items(&db) {
|
||||||
num_decls += 1;
|
num_decls += 1;
|
||||||
match item {
|
match item {
|
||||||
ImplItem::Method(f) => funcs.push(*f),
|
ImplItem::Method(f) => funcs.push(f),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
use ra_db::{CrateId, FileId, SourceRootId, Edition};
|
use ra_db::{CrateId, SourceRootId, Edition};
|
||||||
use ra_syntax::{ast::self, TreeArc, SyntaxNode};
|
use ra_syntax::{ast::self, TreeArc, SyntaxNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
||||||
docs::{Documentation, Docs, docs_from_ast},
|
docs::{Documentation, Docs, docs_from_ast},
|
||||||
module_tree::ModuleId,
|
module_tree::ModuleId,
|
||||||
ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId},
|
ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeId},
|
||||||
impl_block::{ImplId, ImplBlock},
|
impl_block::ImplBlock,
|
||||||
resolve::Resolver,
|
resolve::Resolver,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ impl Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
|
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
|
||||||
pub fn definition_source(&self, db: &impl PersistentHirDatabase) -> (FileId, ModuleSource) {
|
pub fn definition_source(&self, db: &impl PersistentHirDatabase) -> (HirFileId, ModuleSource) {
|
||||||
self.definition_source_impl(db)
|
self.definition_source_impl(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ impl Module {
|
||||||
pub fn declaration_source(
|
pub fn declaration_source(
|
||||||
&self,
|
&self,
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
) -> Option<(FileId, TreeArc<ast::Module>)> {
|
) -> Option<(HirFileId, TreeArc<ast::Module>)> {
|
||||||
self.declaration_source_impl(db)
|
self.declaration_source_impl(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,11 +129,6 @@ impl Module {
|
||||||
self.import_source_impl(db, import)
|
self.import_source_impl(db, import)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the syntax of the impl block in this module
|
|
||||||
pub fn impl_source(&self, db: &impl HirDatabase, impl_id: ImplId) -> TreeArc<ast::ImplBlock> {
|
|
||||||
self.impl_source_impl(db, impl_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the crate this module is part of.
|
/// Returns the crate this module is part of.
|
||||||
pub fn krate(&self, _db: &impl PersistentHirDatabase) -> Option<Crate> {
|
pub fn krate(&self, _db: &impl PersistentHirDatabase) -> Option<Crate> {
|
||||||
Some(self.krate)
|
Some(self.krate)
|
||||||
|
@ -202,7 +197,7 @@ impl Module {
|
||||||
module_impl_blocks
|
module_impl_blocks
|
||||||
.impls
|
.impls
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(impl_id, _)| ImplBlock::from_id(module_impl_blocks.clone(), impl_id))
|
.map(|(impl_id, _)| ImplBlock::from_id(self, impl_id))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use ra_db::FileId;
|
|
||||||
use ra_syntax::{ast, SyntaxNode, TreeArc};
|
use ra_syntax::{ast, SyntaxNode, TreeArc};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Module, ModuleSource, Problem,
|
Module, ModuleSource, Problem,
|
||||||
Name,
|
Name,
|
||||||
module_tree::ModuleId,
|
module_tree::ModuleId,
|
||||||
impl_block::ImplId,
|
nameres::lower::ImportId,
|
||||||
nameres::{lower::ImportId},
|
|
||||||
HirDatabase, PersistentHirDatabase,
|
HirDatabase, PersistentHirDatabase,
|
||||||
|
HirFileId
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Module {
|
impl Module {
|
||||||
|
@ -24,22 +23,21 @@ impl Module {
|
||||||
pub(crate) fn definition_source_impl(
|
pub(crate) fn definition_source_impl(
|
||||||
&self,
|
&self,
|
||||||
db: &impl PersistentHirDatabase,
|
db: &impl PersistentHirDatabase,
|
||||||
) -> (FileId, ModuleSource) {
|
) -> (HirFileId, ModuleSource) {
|
||||||
let module_tree = db.module_tree(self.krate);
|
let module_tree = db.module_tree(self.krate);
|
||||||
let file_id = self.module_id.file_id(&module_tree);
|
let file_id = self.module_id.file_id(&module_tree);
|
||||||
let decl_id = self.module_id.decl_id(&module_tree);
|
let decl_id = self.module_id.decl_id(&module_tree);
|
||||||
let module_source = ModuleSource::new(db, file_id, decl_id);
|
let module_source = ModuleSource::new(db, file_id, decl_id);
|
||||||
let file_id = file_id.as_original_file();
|
|
||||||
(file_id, module_source)
|
(file_id, module_source)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn declaration_source_impl(
|
pub(crate) fn declaration_source_impl(
|
||||||
&self,
|
&self,
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
) -> Option<(FileId, TreeArc<ast::Module>)> {
|
) -> Option<(HirFileId, TreeArc<ast::Module>)> {
|
||||||
let module_tree = db.module_tree(self.krate);
|
let module_tree = db.module_tree(self.krate);
|
||||||
let link = self.module_id.parent_link(&module_tree)?;
|
let link = self.module_id.parent_link(&module_tree)?;
|
||||||
let file_id = link.owner(&module_tree).file_id(&module_tree).as_original_file();
|
let file_id = link.owner(&module_tree).file_id(&module_tree);
|
||||||
let src = link.source(&module_tree, db);
|
let src = link.source(&module_tree, db);
|
||||||
Some((file_id, src))
|
Some((file_id, src))
|
||||||
}
|
}
|
||||||
|
@ -54,16 +52,6 @@ impl Module {
|
||||||
source_map.get(&source, import)
|
source_map.get(&source, import)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn impl_source_impl(
|
|
||||||
&self,
|
|
||||||
db: &impl HirDatabase,
|
|
||||||
impl_id: ImplId,
|
|
||||||
) -> TreeArc<ast::ImplBlock> {
|
|
||||||
let source_map = db.impls_in_module_source_map(*self);
|
|
||||||
let (_, source) = self.definition_source(db);
|
|
||||||
source_map.get(&source, impl_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module {
|
pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module {
|
||||||
let module_tree = db.module_tree(self.krate);
|
let module_tree = db.module_tree(self.krate);
|
||||||
let module_id = self.module_id.crate_root(&module_tree);
|
let module_id = self.module_id.crate_root(&module_tree);
|
||||||
|
|
|
@ -74,7 +74,10 @@ impl HirFileId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn as_original_file(self) -> FileId {
|
/// XXX: this is a temporary function, which should go away when we implement the
|
||||||
|
/// nameresolution+macro expansion combo. Prefer using `original_file` if
|
||||||
|
/// possible.
|
||||||
|
pub fn as_original_file(self) -> FileId {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
HirFileIdRepr::File(file_id) => file_id,
|
HirFileIdRepr::File(file_id) => file_id,
|
||||||
HirFileIdRepr::Macro(_r) => panic!("macro generated file: {:?}", self),
|
HirFileIdRepr::Macro(_r) => panic!("macro generated file: {:?}", self),
|
||||||
|
|
|
@ -38,9 +38,9 @@ impl ImplSourceMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct ImplBlock {
|
pub struct ImplBlock {
|
||||||
module_impl_blocks: Arc<ModuleImplBlocks>,
|
module: Module,
|
||||||
impl_id: ImplId,
|
impl_id: ImplId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,42 +50,45 @@ impl ImplBlock {
|
||||||
item: ImplItem,
|
item: ImplItem,
|
||||||
) -> Option<ImplBlock> {
|
) -> Option<ImplBlock> {
|
||||||
let impl_id = *module_impl_blocks.impls_by_def.get(&item)?;
|
let impl_id = *module_impl_blocks.impls_by_def.get(&item)?;
|
||||||
Some(ImplBlock { module_impl_blocks, impl_id })
|
Some(ImplBlock { module: module_impl_blocks.module, impl_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_id(module_impl_blocks: Arc<ModuleImplBlocks>, impl_id: ImplId) -> ImplBlock {
|
pub(crate) fn from_id(module: Module, impl_id: ImplId) -> ImplBlock {
|
||||||
ImplBlock { module_impl_blocks, impl_id }
|
ImplBlock { module, impl_id }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the syntax of the impl block
|
||||||
|
pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::ImplBlock>) {
|
||||||
|
let source_map = db.impls_in_module_source_map(self.module);
|
||||||
|
let (file_id, source) = self.module.definition_source(db);
|
||||||
|
(file_id, source_map.get(&source, self.impl_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> ImplId {
|
pub fn id(&self) -> ImplId {
|
||||||
self.impl_id
|
self.impl_id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn impl_data(&self) -> &ImplData {
|
|
||||||
&self.module_impl_blocks.impls[self.impl_id]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn module(&self) -> Module {
|
pub fn module(&self) -> Module {
|
||||||
self.module_impl_blocks.module
|
self.module
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_trait_ref(&self) -> Option<&TypeRef> {
|
pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TypeRef> {
|
||||||
self.impl_data().target_trait()
|
db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_type(&self) -> &TypeRef {
|
pub fn target_type(&self, db: &impl HirDatabase) -> TypeRef {
|
||||||
self.impl_data().target_type()
|
db.impls_in_module(self.module).impls[self.impl_id].target_type().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_ty(&self, db: &impl HirDatabase) -> Ty {
|
pub fn target_ty(&self, db: &impl HirDatabase) -> Ty {
|
||||||
Ty::from_hir(db, &self.resolver(db), self.target_type())
|
Ty::from_hir(db, &self.resolver(db), &self.target_type(db))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_trait(&self, db: &impl HirDatabase) -> Option<Trait> {
|
pub fn target_trait(&self, db: &impl HirDatabase) -> Option<Trait> {
|
||||||
if let Some(TypeRef::Path(path)) = self.target_trait_ref() {
|
if let Some(TypeRef::Path(path)) = self.target_trait_ref(db) {
|
||||||
let resolver = self.resolver(db);
|
let resolver = self.resolver(db);
|
||||||
if let Some(Resolution::Def(ModuleDef::Trait(tr))) =
|
if let Some(Resolution::Def(ModuleDef::Trait(tr))) =
|
||||||
resolver.resolve_path(db, path).take_types()
|
resolver.resolve_path(db, &path).take_types()
|
||||||
{
|
{
|
||||||
return Some(tr);
|
return Some(tr);
|
||||||
}
|
}
|
||||||
|
@ -93,8 +96,8 @@ impl ImplBlock {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items(&self) -> &[ImplItem] {
|
pub fn items(&self, db: &impl HirDatabase) -> Vec<ImplItem> {
|
||||||
self.impl_data().items()
|
db.impls_in_module(self.module).impls[self.impl_id].items().to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
|
pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
|
||||||
|
@ -181,7 +184,7 @@ impl_arena_id!(ImplId);
|
||||||
/// we don't need to do the second step again.
|
/// we don't need to do the second step again.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct ModuleImplBlocks {
|
pub struct ModuleImplBlocks {
|
||||||
module: Module,
|
pub(crate) module: Module,
|
||||||
pub(crate) impls: Arena<ImplId, ImplData>,
|
pub(crate) impls: Arena<ImplId, ImplData>,
|
||||||
impls_by_def: FxHashMap<ImplItem, ImplId>,
|
impls_by_def: FxHashMap<ImplItem, ImplId>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,32 +40,25 @@ pub struct CrateImplBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CrateImplBlocks {
|
impl CrateImplBlocks {
|
||||||
pub fn lookup_impl_blocks<'a>(
|
pub fn lookup_impl_blocks<'a>(&'a self, ty: &Ty) -> impl Iterator<Item = ImplBlock> + 'a {
|
||||||
&'a self,
|
|
||||||
db: &'a impl HirDatabase,
|
|
||||||
ty: &Ty,
|
|
||||||
) -> impl Iterator<Item = (Module, ImplBlock)> + 'a {
|
|
||||||
let fingerprint = TyFingerprint::for_impl(ty);
|
let fingerprint = TyFingerprint::for_impl(ty);
|
||||||
fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map(
|
fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map(
|
||||||
move |(module_id, impl_id)| {
|
move |(module_id, impl_id)| {
|
||||||
let module = Module { krate: self.krate, module_id: *module_id };
|
let module = Module { krate: self.krate, module_id: *module_id };
|
||||||
let module_impl_blocks = db.impls_in_module(module);
|
ImplBlock::from_id(module, *impl_id)
|
||||||
(module, ImplBlock::from_id(module_impl_blocks, *impl_id))
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lookup_impl_blocks_for_trait<'a>(
|
pub fn lookup_impl_blocks_for_trait<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
db: &'a impl HirDatabase,
|
|
||||||
tr: &Trait,
|
tr: &Trait,
|
||||||
) -> impl Iterator<Item = (Module, ImplBlock)> + 'a {
|
) -> impl Iterator<Item = ImplBlock> + 'a {
|
||||||
let id = tr.id;
|
let id = tr.id;
|
||||||
self.impls_by_trait.get(&id).into_iter().flat_map(|i| i.iter()).map(
|
self.impls_by_trait.get(&id).into_iter().flat_map(|i| i.iter()).map(
|
||||||
move |(module_id, impl_id)| {
|
move |(module_id, impl_id)| {
|
||||||
let module = Module { krate: self.krate, module_id: *module_id };
|
let module = Module { krate: self.krate, module_id: *module_id };
|
||||||
let module_impl_blocks = db.impls_in_module(module);
|
ImplBlock::from_id(module, *impl_id)
|
||||||
(module, ImplBlock::from_id(module_impl_blocks, *impl_id))
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -74,7 +67,7 @@ impl CrateImplBlocks {
|
||||||
let module_impl_blocks = db.impls_in_module(module.clone());
|
let module_impl_blocks = db.impls_in_module(module.clone());
|
||||||
|
|
||||||
for (impl_id, _) in module_impl_blocks.impls.iter() {
|
for (impl_id, _) in module_impl_blocks.impls.iter() {
|
||||||
let impl_block = ImplBlock::from_id(Arc::clone(&module_impl_blocks), impl_id);
|
let impl_block = ImplBlock::from_id(module_impl_blocks.module, impl_id);
|
||||||
|
|
||||||
let target_ty = impl_block.target_ty(db);
|
let target_ty = impl_block.target_ty(db);
|
||||||
|
|
||||||
|
@ -159,11 +152,11 @@ impl Ty {
|
||||||
};
|
};
|
||||||
let impls = db.impls_in_crate(krate);
|
let impls = db.impls_in_crate(krate);
|
||||||
|
|
||||||
for (_, impl_block) in impls.lookup_impl_blocks(db, &derefed_ty) {
|
for impl_block in impls.lookup_impl_blocks(&derefed_ty) {
|
||||||
for item in impl_block.items() {
|
for item in impl_block.items(db) {
|
||||||
match item {
|
match item {
|
||||||
ImplItem::Method(f) => {
|
ImplItem::Method(f) => {
|
||||||
if let Some(result) = callback(*f) {
|
if let Some(result) = callback(f) {
|
||||||
return Some(result);
|
return Some(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,9 +178,9 @@ impl Ty {
|
||||||
let krate = def_crate(db, &self)?;
|
let krate = def_crate(db, &self)?;
|
||||||
let impls = db.impls_in_crate(krate);
|
let impls = db.impls_in_crate(krate);
|
||||||
|
|
||||||
for (_, impl_block) in impls.lookup_impl_blocks(db, &self) {
|
for impl_block in impls.lookup_impl_blocks(&self) {
|
||||||
for item in impl_block.items() {
|
for item in impl_block.items(db) {
|
||||||
if let Some(result) = callback(*item) {
|
if let Some(result) = callback(item) {
|
||||||
return Some(result);
|
return Some(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ fn impls_for_def(
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
impls
|
impls
|
||||||
.lookup_impl_blocks(db, &ty)
|
.lookup_impl_blocks(&ty)
|
||||||
.map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp))
|
.map(|imp| NavigationTarget::from_impl_block(db, imp))
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ fn impls_for_trait(
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
impls
|
impls
|
||||||
.lookup_impl_blocks_for_trait(db, &tr)
|
.lookup_impl_blocks_for_trait(&tr)
|
||||||
.map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp))
|
.map(|imp| NavigationTarget::from_impl_block(db, imp))
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ impl NavigationTarget {
|
||||||
|
|
||||||
pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
|
pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
|
||||||
let (file_id, source) = module.definition_source(db);
|
let (file_id, source) = module.definition_source(db);
|
||||||
|
let file_id = file_id.as_original_file();
|
||||||
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
|
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
|
||||||
match source {
|
match source {
|
||||||
ModuleSource::SourceFile(node) => {
|
ModuleSource::SourceFile(node) => {
|
||||||
|
@ -93,6 +94,7 @@ impl NavigationTarget {
|
||||||
pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
|
pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
|
||||||
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
|
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
|
||||||
if let Some((file_id, source)) = module.declaration_source(db) {
|
if let Some((file_id, source)) = module.declaration_source(db) {
|
||||||
|
let file_id = file_id.as_original_file();
|
||||||
return NavigationTarget::from_syntax(file_id, name, None, source.syntax());
|
return NavigationTarget::from_syntax(file_id, name, None, source.syntax());
|
||||||
}
|
}
|
||||||
NavigationTarget::from_module(db, module)
|
NavigationTarget::from_module(db, module)
|
||||||
|
@ -151,12 +153,15 @@ impl NavigationTarget {
|
||||||
|
|
||||||
pub(crate) fn from_impl_block(
|
pub(crate) fn from_impl_block(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
module: hir::Module,
|
impl_block: hir::ImplBlock,
|
||||||
impl_block: &hir::ImplBlock,
|
|
||||||
) -> NavigationTarget {
|
) -> NavigationTarget {
|
||||||
let (file_id, _) = module.definition_source(db);
|
let (file_id, node) = impl_block.source(db);
|
||||||
let node = module.impl_source(db, impl_block.id());
|
NavigationTarget::from_syntax(
|
||||||
NavigationTarget::from_syntax(file_id, "impl".into(), None, node.syntax())
|
file_id.as_original_file(),
|
||||||
|
"impl".into(),
|
||||||
|
None,
|
||||||
|
node.syntax(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -100,6 +100,7 @@ fn rename_mod(
|
||||||
if let Some(module) = source_binder::module_from_declaration(db, position.file_id, &ast_module)
|
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, module_source) = module.definition_source(db);
|
||||||
|
let file_id = file_id.as_original_file();
|
||||||
match module_source {
|
match module_source {
|
||||||
ModuleSource::SourceFile(..) => {
|
ModuleSource::SourceFile(..) => {
|
||||||
let mod_path: RelativePathBuf = db.file_relative_path(file_id);
|
let mod_path: RelativePathBuf = db.file_relative_path(file_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue