mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
container name?
This commit is contained in:
parent
a1030b07ab
commit
377162c0f8
2 changed files with 24 additions and 7 deletions
|
@ -44,9 +44,9 @@ use hir_def::{
|
||||||
nameres,
|
nameres,
|
||||||
per_ns::PerNs,
|
per_ns::PerNs,
|
||||||
resolver::{HasResolver, Resolver},
|
resolver::{HasResolver, Resolver},
|
||||||
AssocContainerId, AssocItemId, AttrDefId, ConstId, ConstParamId, DefWithBodyId, EnumId,
|
AssocItemId, AttrDefId, ConstId, ConstParamId, DefWithBodyId, EnumId, FunctionId, GenericDefId,
|
||||||
FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId, LocalEnumVariantId, LocalFieldId,
|
HasModule, ImplId, LifetimeParamId, LocalEnumVariantId, LocalFieldId, StaticId, StructId,
|
||||||
StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
|
TraitId, TypeAliasId, TypeParamId, UnionId,
|
||||||
};
|
};
|
||||||
use hir_expand::{name::name, MacroCallKind, MacroDefId, MacroDefKind};
|
use hir_expand::{name::name, MacroCallKind, MacroDefId, MacroDefKind};
|
||||||
use hir_ty::{
|
use hir_ty::{
|
||||||
|
@ -114,6 +114,7 @@ pub use {
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
visibility::Visibility,
|
visibility::Visibility,
|
||||||
AdtId,
|
AdtId,
|
||||||
|
AssocContainerId,
|
||||||
AssocItemLoc,
|
AssocItemLoc,
|
||||||
ItemLoc,
|
ItemLoc,
|
||||||
Lookup,
|
Lookup,
|
||||||
|
|
|
@ -34,8 +34,8 @@ use base_db::{
|
||||||
};
|
};
|
||||||
use fst::{self, Streamer};
|
use fst::{self, Streamer};
|
||||||
use hir::{
|
use hir::{
|
||||||
db::DefDatabase, AdtId, AssocItemLoc, DefHasSource, HirFileId, ItemLoc, ItemScope,
|
db::DefDatabase, AdtId, AssocContainerId, AssocItemLoc, DefHasSource, HirFileId, ItemLoc,
|
||||||
ItemTreeNode, Lookup, ModuleData, ModuleDefId, ModuleId,
|
ItemScope, ItemTreeNode, Lookup, ModuleData, ModuleDefId, ModuleId,
|
||||||
};
|
};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
@ -516,12 +516,28 @@ fn collect_symbols_from_item_scope(
|
||||||
let name = name.text().into();
|
let name = name.text().into();
|
||||||
let ptr = SyntaxNodePtr::new(source.value.syntax());
|
let ptr = SyntaxNodePtr::new(source.value.syntax());
|
||||||
|
|
||||||
|
let container_name = match loc.container {
|
||||||
|
AssocContainerId::ModuleId(module_id) => {
|
||||||
|
let def_map = module_id.def_map(db);
|
||||||
|
let module_data = &def_map[module_id.local_id];
|
||||||
|
module_data
|
||||||
|
.origin
|
||||||
|
.declaration()
|
||||||
|
.and_then(|s| s.to_node(db.upcast()).name().map(|n| n.text().into()))
|
||||||
|
}
|
||||||
|
AssocContainerId::TraitId(trait_id) => {
|
||||||
|
let loc = trait_id.lookup(db);
|
||||||
|
let source = loc.source(db);
|
||||||
|
source.value.name().map(|n| n.text().into())
|
||||||
|
}
|
||||||
|
AssocContainerId::ImplId(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
Some(FileSymbol {
|
Some(FileSymbol {
|
||||||
name,
|
name,
|
||||||
kind,
|
kind,
|
||||||
range: source.value.syntax().text_range(),
|
range: source.value.syntax().text_range(),
|
||||||
// todo: fill out based on loc.container.
|
container_name,
|
||||||
container_name: None,
|
|
||||||
file_id,
|
file_id,
|
||||||
name_range: Some(name_range),
|
name_range: Some(name_range),
|
||||||
ptr,
|
ptr,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue