Rename GenericParam -> TypeParam

We don't have LifetimeParam yet, but they are planned!
This commit is contained in:
Aleksey Kladov 2019-12-07 20:09:53 +01:00
parent f4f8b81474
commit 88c5b1282a
18 changed files with 77 additions and 79 deletions

View file

@ -351,7 +351,7 @@ impl ToNav for hir::Local {
}
}
impl ToNav for hir::GenericParam {
impl ToNav for hir::TypeParam {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
let src = self.source(db);
let range = match src.value {

View file

@ -66,7 +66,7 @@ pub(crate) fn reference_definition(
match name_kind {
Some(Macro(it)) => return Exact(it.to_nav(db)),
Some(Field(it)) => return Exact(it.to_nav(db)),
Some(GenericParam(it)) => return Exact(it.to_nav(db)),
Some(TypeParam(it)) => return Exact(it.to_nav(db)),
Some(AssocItem(it)) => return Exact(it.to_nav(db)),
Some(Local(it)) => return Exact(it.to_nav(db)),
Some(Def(def)) => match NavigationTarget::from_def(db, def) {

View file

@ -138,7 +138,7 @@ fn hover_text_from_name_kind(
*no_fallback = true;
None
}
GenericParam(_) | SelfType(_) => {
TypeParam(_) | SelfType(_) => {
// FIXME: Hover for generic param
None
}

View file

@ -85,7 +85,7 @@ pub(crate) fn find_all_refs(
NameKind::Def(def) => NavigationTarget::from_def(db, def)?,
NameKind::SelfType(imp) => imp.to_nav(db),
NameKind::Local(local) => local.to_nav(db),
NameKind::GenericParam(_) => return None,
NameKind::TypeParam(_) => return None,
};
let search_scope = {

View file

@ -112,11 +112,11 @@ pub(crate) fn classify_name(db: &RootDatabase, name: InFile<&ast::Name>) -> Opti
},
ast::TypeParam(it) => {
let src = name.with_value(it);
let def = hir::GenericParam::from_source(db, src)?;
let def = hir::TypeParam::from_source(db, src)?;
Some(NameDefinition {
visibility: None,
container: def.module(db),
kind: NameKind::GenericParam(def),
kind: NameKind::TypeParam(def),
})
},
_ => None,
@ -177,8 +177,8 @@ pub(crate) fn classify_name_ref(
let kind = NameKind::Local(local);
Some(NameDefinition { kind, container, visibility: None })
}
PathResolution::GenericParam(par) => {
let kind = NameKind::GenericParam(par);
PathResolution::TypeParam(par) => {
let kind = NameKind::TypeParam(par);
Some(NameDefinition { kind, container, visibility })
}
PathResolution::Macro(def) => {

View file

@ -4,8 +4,8 @@
//! Note that the reference search is possible for not all of the classified items.
use hir::{
Adt, AssocItem, GenericParam, HasSource, ImplBlock, Local, MacroDef, Module, ModuleDef,
StructField, VariantDef,
Adt, AssocItem, HasSource, ImplBlock, Local, MacroDef, Module, ModuleDef, StructField,
TypeParam, VariantDef,
};
use ra_syntax::{ast, ast::VisibilityOwner};
@ -19,7 +19,7 @@ pub enum NameKind {
Def(ModuleDef),
SelfType(ImplBlock),
Local(Local),
GenericParam(GenericParam),
TypeParam(TypeParam),
}
#[derive(PartialEq, Eq)]

View file

@ -9,6 +9,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
.parameter { color: #94BFF3; }
.builtin { color: #DD6718; }
.text { color: #DCDCCC; }
.type { color: #7CB8BB; }
.attribute { color: #94BFF3; }
.literal { color: #BFEBBF; }
.macro { color: #94BFF3; }

View file

@ -225,8 +225,7 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
Def(hir::ModuleDef::Trait(_)) => "type",
Def(hir::ModuleDef::TypeAlias(_)) => "type",
Def(hir::ModuleDef::BuiltinType(_)) => "type",
SelfType(_) => "type",
GenericParam(_) => "type",
SelfType(_) | TypeParam(_) => "type",
Local(local) => {
if local.is_mut(db) {
"variable.mut"