mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Rename
This commit is contained in:
parent
f55be75a17
commit
ae70d07237
6 changed files with 23 additions and 23 deletions
|
@ -76,10 +76,10 @@ pub(crate) fn reference_definition(
|
||||||
let name_kind = classify_name_ref(sb, name_ref).map(|d| d.kind);
|
let name_kind = classify_name_ref(sb, name_ref).map(|d| d.kind);
|
||||||
match name_kind {
|
match name_kind {
|
||||||
Some(Macro(it)) => return Exact(it.to_nav(sb.db)),
|
Some(Macro(it)) => return Exact(it.to_nav(sb.db)),
|
||||||
Some(Field(it)) => return Exact(it.to_nav(sb.db)),
|
Some(StructField(it)) => return Exact(it.to_nav(sb.db)),
|
||||||
Some(TypeParam(it)) => return Exact(it.to_nav(sb.db)),
|
Some(TypeParam(it)) => return Exact(it.to_nav(sb.db)),
|
||||||
Some(Local(it)) => return Exact(it.to_nav(sb.db)),
|
Some(Local(it)) => return Exact(it.to_nav(sb.db)),
|
||||||
Some(Def(def)) => match NavigationTarget::from_def(sb.db, def) {
|
Some(ModuleDef(def)) => match NavigationTarget::from_def(sb.db, def) {
|
||||||
Some(nav) => return Exact(nav),
|
Some(nav) => return Exact(nav),
|
||||||
None => return Approximate(vec![]),
|
None => return Approximate(vec![]),
|
||||||
},
|
},
|
||||||
|
|
|
@ -98,14 +98,14 @@ fn hover_text_from_name_kind(db: &RootDatabase, name_kind: NameKind) -> Option<S
|
||||||
let src = it.source(db);
|
let src = it.source(db);
|
||||||
hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value)))
|
hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value)))
|
||||||
}
|
}
|
||||||
Field(it) => {
|
StructField(it) => {
|
||||||
let src = it.source(db);
|
let src = it.source(db);
|
||||||
match src.value {
|
match src.value {
|
||||||
hir::FieldSource::Named(it) => hover_text(it.doc_comment_text(), it.short_label()),
|
hir::FieldSource::Named(it) => hover_text(it.doc_comment_text(), it.short_label()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Def(it) => match it {
|
ModuleDef(it) => match it {
|
||||||
hir::ModuleDef::Module(it) => match it.definition_source(db).value {
|
hir::ModuleDef::Module(it) => match it.definition_source(db).value {
|
||||||
hir::ModuleSource::Module(it) => {
|
hir::ModuleSource::Module(it) => {
|
||||||
hover_text(it.doc_comment_text(), it.short_label())
|
hover_text(it.doc_comment_text(), it.short_label())
|
||||||
|
|
|
@ -127,8 +127,8 @@ pub(crate) fn find_all_refs(
|
||||||
|
|
||||||
let declaration = match def.kind {
|
let declaration = match def.kind {
|
||||||
NameKind::Macro(mac) => mac.to_nav(db),
|
NameKind::Macro(mac) => mac.to_nav(db),
|
||||||
NameKind::Field(field) => field.to_nav(db),
|
NameKind::StructField(field) => field.to_nav(db),
|
||||||
NameKind::Def(def) => NavigationTarget::from_def(db, def)?,
|
NameKind::ModuleDef(def) => NavigationTarget::from_def(db, def)?,
|
||||||
NameKind::SelfType(imp) => imp.to_nav(db),
|
NameKind::SelfType(imp) => imp.to_nav(db),
|
||||||
NameKind::Local(local) => local.to_nav(db),
|
NameKind::Local(local) => local.to_nav(db),
|
||||||
NameKind::TypeParam(_) => return None,
|
NameKind::TypeParam(_) => return None,
|
||||||
|
@ -239,7 +239,7 @@ fn decl_access(
|
||||||
range: TextRange,
|
range: TextRange,
|
||||||
) -> Option<ReferenceAccess> {
|
) -> Option<ReferenceAccess> {
|
||||||
match kind {
|
match kind {
|
||||||
NameKind::Local(_) | NameKind::Field(_) => {}
|
NameKind::Local(_) | NameKind::StructField(_) => {}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ fn decl_access(
|
||||||
fn reference_access(kind: &NameKind, name_ref: &ast::NameRef) -> Option<ReferenceAccess> {
|
fn reference_access(kind: &NameKind, name_ref: &ast::NameRef) -> Option<ReferenceAccess> {
|
||||||
// Only Locals and Fields have accesses for now.
|
// Only Locals and Fields have accesses for now.
|
||||||
match kind {
|
match kind {
|
||||||
NameKind::Local(_) | NameKind::Field(_) => {}
|
NameKind::Local(_) | NameKind::StructField(_) => {}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -320,16 +320,16 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
|
||||||
fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
|
fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
|
||||||
match name_kind {
|
match name_kind {
|
||||||
Macro(_) => tags::MACRO,
|
Macro(_) => tags::MACRO,
|
||||||
Field(_) => tags::FIELD,
|
StructField(_) => tags::FIELD,
|
||||||
Def(hir::ModuleDef::Module(_)) => tags::MODULE,
|
ModuleDef(hir::ModuleDef::Module(_)) => tags::MODULE,
|
||||||
Def(hir::ModuleDef::Function(_)) => tags::FUNCTION,
|
ModuleDef(hir::ModuleDef::Function(_)) => tags::FUNCTION,
|
||||||
Def(hir::ModuleDef::Adt(_)) => tags::TYPE,
|
ModuleDef(hir::ModuleDef::Adt(_)) => tags::TYPE,
|
||||||
Def(hir::ModuleDef::EnumVariant(_)) => tags::CONSTANT,
|
ModuleDef(hir::ModuleDef::EnumVariant(_)) => tags::CONSTANT,
|
||||||
Def(hir::ModuleDef::Const(_)) => tags::CONSTANT,
|
ModuleDef(hir::ModuleDef::Const(_)) => tags::CONSTANT,
|
||||||
Def(hir::ModuleDef::Static(_)) => tags::CONSTANT,
|
ModuleDef(hir::ModuleDef::Static(_)) => tags::CONSTANT,
|
||||||
Def(hir::ModuleDef::Trait(_)) => tags::TYPE,
|
ModuleDef(hir::ModuleDef::Trait(_)) => tags::TYPE,
|
||||||
Def(hir::ModuleDef::TypeAlias(_)) => tags::TYPE,
|
ModuleDef(hir::ModuleDef::TypeAlias(_)) => tags::TYPE,
|
||||||
Def(hir::ModuleDef::BuiltinType(_)) => tags::TYPE_BUILTIN,
|
ModuleDef(hir::ModuleDef::BuiltinType(_)) => tags::TYPE_BUILTIN,
|
||||||
SelfType(_) => tags::TYPE_SELF,
|
SelfType(_) => tags::TYPE_SELF,
|
||||||
TypeParam(_) => tags::TYPE_PARAM,
|
TypeParam(_) => tags::TYPE_PARAM,
|
||||||
Local(local) => {
|
Local(local) => {
|
||||||
|
|
|
@ -20,8 +20,8 @@ use crate::RootDatabase;
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum NameKind {
|
pub enum NameKind {
|
||||||
Macro(MacroDef),
|
Macro(MacroDef),
|
||||||
Field(StructField),
|
StructField(StructField),
|
||||||
Def(ModuleDef),
|
ModuleDef(ModuleDef),
|
||||||
SelfType(ImplBlock),
|
SelfType(ImplBlock),
|
||||||
Local(Local),
|
Local(Local),
|
||||||
TypeParam(TypeParam),
|
TypeParam(TypeParam),
|
||||||
|
@ -130,7 +130,7 @@ pub fn classify_name(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_struct_field(db: &RootDatabase, field: StructField) -> NameDefinition {
|
pub fn from_struct_field(db: &RootDatabase, field: StructField) -> NameDefinition {
|
||||||
let kind = NameKind::Field(field);
|
let kind = NameKind::StructField(field);
|
||||||
let parent = field.parent_def(db);
|
let parent = field.parent_def(db);
|
||||||
let container = parent.module(db);
|
let container = parent.module(db);
|
||||||
let visibility = match parent {
|
let visibility = match parent {
|
||||||
|
@ -146,7 +146,7 @@ pub fn from_module_def(
|
||||||
def: ModuleDef,
|
def: ModuleDef,
|
||||||
module: Option<Module>,
|
module: Option<Module>,
|
||||||
) -> NameDefinition {
|
) -> NameDefinition {
|
||||||
let kind = NameKind::Def(def);
|
let kind = NameKind::ModuleDef(def);
|
||||||
let (container, visibility) = match def {
|
let (container, visibility) = match def {
|
||||||
ModuleDef::Module(it) => {
|
ModuleDef::Module(it) => {
|
||||||
let container = it.parent(db).or_else(|| Some(it)).unwrap();
|
let container = it.parent(db).or_else(|| Some(it)).unwrap();
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl<'a> ImportsLocator<'a> {
|
||||||
.chain(lib_results.into_iter())
|
.chain(lib_results.into_iter())
|
||||||
.filter_map(|import_candidate| self.get_name_definition(db, &import_candidate))
|
.filter_map(|import_candidate| self.get_name_definition(db, &import_candidate))
|
||||||
.filter_map(|name_definition_to_import| match name_definition_to_import {
|
.filter_map(|name_definition_to_import| match name_definition_to_import {
|
||||||
NameKind::Def(module_def) => Some(module_def),
|
NameKind::ModuleDef(module_def) => Some(module_def),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue