From 88c5b1282a5770097c6c768b24bedfc3a6944e08 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 20:09:53 +0100 Subject: Rename GenericParam -> TypeParam We don't have LifetimeParam yet, but they are planned! --- crates/ra_hir/src/code_model.rs | 16 ++++++------- crates/ra_hir/src/code_model/src.rs | 6 ++--- crates/ra_hir/src/from_source.rs | 8 +++---- crates/ra_hir/src/lib.rs | 6 ++--- crates/ra_hir/src/source_binder.rs | 10 ++++---- crates/ra_hir_def/src/generics.rs | 28 +++++++++++----------- crates/ra_hir_def/src/keys.rs | 4 ++-- crates/ra_hir_def/src/lib.rs | 8 +++---- crates/ra_hir_def/src/resolver.rs | 18 +++++++------- crates/ra_hir_ty/src/utils.rs | 26 ++++++++++---------- crates/ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/goto_definition.rs | 2 +- crates/ra_ide/src/hover.rs | 2 +- crates/ra_ide/src/references.rs | 2 +- crates/ra_ide/src/references/classify.rs | 8 +++---- crates/ra_ide/src/references/name_definition.rs | 6 ++--- .../ra_ide/src/snapshots/rainbow_highlighting.html | 1 + crates/ra_ide/src/syntax_highlighting.rs | 3 +-- 18 files changed, 77 insertions(+), 79 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 0295eb948..4578a0ba8 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -15,9 +15,9 @@ use hir_def::{ per_ns::PerNs, resolver::HasResolver, type_ref::{Mutability, TypeRef}, - AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, FunctionId, GenericParamId, - HasModule, ImplId, LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, - Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, UnionId, + AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, FunctionId, HasModule, ImplId, + LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId, + StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, }; use hir_expand::{ diagnostics::DiagnosticSink, @@ -856,14 +856,14 @@ impl Local { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub struct GenericParam { - pub(crate) id: GenericParamId, +pub struct TypeParam { + pub(crate) id: TypeParamId, } -impl GenericParam { +impl TypeParam { pub fn name(self, db: &impl HirDatabase) -> Name { let params = db.generic_params(self.id.parent); - params.params[self.id.local_id].name.clone() + params.types[self.id.local_id].name.clone() } pub fn module(self, db: &impl HirDatabase) -> Module { @@ -1111,7 +1111,7 @@ impl HirDisplay for Type { pub enum ScopeDef { ModuleDef(ModuleDef), MacroDef(MacroDef), - GenericParam(GenericParam), + GenericParam(TypeParam), ImplSelfType(ImplBlock), AdtSelfType(Adt), Local(Local), diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 8f04ebd23..b09582f93 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs @@ -9,8 +9,8 @@ use hir_def::{ use ra_syntax::ast; use crate::{ - db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, GenericParam, ImplBlock, - Import, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, + db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, + Module, Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, }; pub use hir_expand::InFile; @@ -130,7 +130,7 @@ impl HasSource for Import { } } -impl HasSource for GenericParam { +impl HasSource for TypeParam { type Ast = Either; fn source(self, db: &impl DefDatabase) -> InFile { let child_source = self.id.parent.child_source(db); diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 686ab1d79..68e59fc1e 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -11,8 +11,8 @@ use ra_syntax::{ use crate::{ db::{AstDatabase, DefDatabase, HirDatabase}, - Const, DefWithBody, Enum, EnumVariant, FieldSource, Function, GenericParam, ImplBlock, InFile, - Local, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, + Const, DefWithBody, Enum, EnumVariant, FieldSource, Function, ImplBlock, InFile, Local, + MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, }; pub trait FromSource: Sized { @@ -177,7 +177,7 @@ impl Local { } } -impl GenericParam { +impl TypeParam { pub fn from_source(db: &impl HirDatabase, src: InFile) -> Option { let file_id = src.file_id; let parent: GenericDefId = src.value.syntax().ancestors().find_map(|it| { @@ -190,7 +190,7 @@ impl GenericParam { Some(res) })?; let &id = parent.child_by_source(db)[keys::TYPE_PARAM].get(&src)?; - Some(GenericParam { id }) + Some(TypeParam { id }) } } diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index f12e4ca3f..9eb34b5dc 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -42,9 +42,9 @@ pub mod from_source; pub use crate::{ code_model::{ src::HasSource, Adt, AssocItem, AttrDef, Const, Container, Crate, CrateDependency, - DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, GenericParam, - HasAttrs, ImplBlock, Import, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, - StructField, Trait, Type, TypeAlias, Union, VariantDef, + DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, + ImplBlock, Import, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, + StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, }, from_source::FromSource, source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 2957e496c..b80aaeb90 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -36,8 +36,8 @@ use crate::{ method_resolution::{self, implements_trait}, InEnvironment, TraitEnvironment, Ty, }, - Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, - ImplBlock, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, + Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, ImplBlock, Local, + MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, }; fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option { @@ -112,7 +112,7 @@ pub enum PathResolution { /// A local binding (only value namespace) Local(Local), /// A generic parameter - GenericParam(GenericParam), + TypeParam(TypeParam), SelfType(crate::ImplBlock), Macro(MacroDef), AssocItem(crate::AssocItem), @@ -266,7 +266,7 @@ impl SourceAnalyzer { ) -> Option { let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), - TypeNs::GenericParam(id) => PathResolution::GenericParam(GenericParam { id }), + TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }), TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { PathResolution::Def(Adt::from(it).into()) } @@ -338,7 +338,7 @@ impl SourceAnalyzer { resolver::ScopeDef::PerNs(it) => it.into(), resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), - resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(GenericParam { id }), + resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }), resolver::ScopeDef::Local(pat_id) => { let parent = self.resolver.body_owner().unwrap().into(); ScopeDef::Local(Local { parent, pat_id }) diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 159f9034b..976cf72d0 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -21,12 +21,12 @@ use crate::{ src::HasChildSource, src::HasSource, type_ref::{TypeBound, TypeRef}, - AdtId, AstItemDef, GenericDefId, GenericParamId, LocalGenericParamId, Lookup, + AdtId, AstItemDef, GenericDefId, LocalTypeParamId, Lookup, TypeParamId, }; /// Data about a generic parameter (to a function, struct, impl, ...). #[derive(Clone, PartialEq, Eq, Debug)] -pub struct GenericParamData { +pub struct TypeParamData { pub name: Name, pub default: Option, } @@ -34,7 +34,8 @@ pub struct GenericParamData { /// Data about the generic parameters of a function, struct, impl, etc. #[derive(Clone, PartialEq, Eq, Debug)] pub struct GenericParams { - pub params: Arena, + pub types: Arena, + // lifetimes: Arena, pub where_predicates: Vec, } @@ -48,7 +49,7 @@ pub struct WherePredicate { pub bound: TypeBound, } -type SourceMap = ArenaMap>; +type SourceMap = ArenaMap>; impl GenericParams { pub(crate) fn generic_params_query( @@ -60,7 +61,7 @@ impl GenericParams { } fn new(db: &impl DefDatabase, def: GenericDefId) -> (GenericParams, InFile) { - let mut generics = GenericParams { params: Arena::default(), where_predicates: Vec::new() }; + let mut generics = GenericParams { types: Arena::default(), where_predicates: Vec::new() }; let mut sm = ArenaMap::default(); // FIXME: add `: Sized` bound for everything except for `Self` in traits let file_id = match def { @@ -88,9 +89,8 @@ impl GenericParams { let src = it.source(db); // traits get the Self type as an implicit first type parameter - let self_param_id = generics - .params - .alloc(GenericParamData { name: name::SELF_TYPE, default: None }); + let self_param_id = + generics.types.alloc(TypeParamData { name: name::SELF_TYPE, default: None }); sm.insert(self_param_id, Either::Left(src.value.clone())); // add super traits as bounds on Self // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar @@ -142,8 +142,8 @@ impl GenericParams { let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); // FIXME: Use `Path::from_src` let default = type_param.default_type().map(TypeRef::from_ast); - let param = GenericParamData { name: name.clone(), default }; - let param_id = self.params.alloc(param); + let param = TypeParamData { name: name.clone(), default }; + let param_id = self.types.alloc(param); sm.insert(param_id, Either::Right(type_param.clone())); let type_ref = TypeRef::Path(name.into()); @@ -173,13 +173,13 @@ impl GenericParams { self.where_predicates.push(WherePredicate { type_ref, bound }); } - pub fn find_by_name(&self, name: &Name) -> Option { - self.params.iter().find_map(|(id, p)| if &p.name == name { Some(id) } else { None }) + pub fn find_by_name(&self, name: &Name) -> Option { + self.types.iter().find_map(|(id, p)| if &p.name == name { Some(id) } else { None }) } } impl HasChildSource for GenericDefId { - type ChildId = LocalGenericParamId; + type ChildId = LocalTypeParamId; type Value = Either; fn child_source(&self, db: &impl DefDatabase) -> InFile { let (_, sm) = GenericParams::new(db, *self); @@ -193,7 +193,7 @@ impl ChildBySource for GenericDefId { let arena_map = self.child_source(db); let arena_map = arena_map.as_ref(); for (local_id, src) in arena_map.value.iter() { - let id = GenericParamId { parent: *self, local_id }; + let id = TypeParamId { parent: *self, local_id }; if let Either::Right(type_param) = src { res[keys::TYPE_PARAM].insert(arena_map.with_value(type_param.clone()), id) } diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index ca5630c80..be702a4f8 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; use crate::{ dyn_map::{DynMap, Policy}, - ConstId, EnumVariantId, FunctionId, GenericParamId, StaticId, StructFieldId, TypeAliasId, + ConstId, EnumVariantId, FunctionId, StaticId, StructFieldId, TypeAliasId, TypeParamId, }; type Key = crate::dyn_map::Key, V, AstPtrPolicy>; @@ -20,7 +20,7 @@ pub const ENUM_VARIANT: Key = Key::new(); pub const TYPE_ALIAS: Key = Key::new(); pub const TUPLE_FIELD: Key = Key::new(); pub const RECORD_FIELD: Key = Key::new(); -pub const TYPE_PARAM: Key = Key::new(); +pub const TYPE_PARAM: Key = Key::new(); /// XXX: AST Nodes and SyntaxNodes have identity equality semantics: nodes are /// equal if they point to exactly the same object. diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 6dfb3c03d..569da4f28 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -318,14 +318,14 @@ macro_rules! impl_froms { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct GenericParamId { +pub struct TypeParamId { pub parent: GenericDefId, - pub local_id: LocalGenericParamId, + pub local_id: LocalTypeParamId, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct LocalGenericParamId(RawId); -impl_arena_id!(LocalGenericParamId); +pub struct LocalTypeParamId(RawId); +impl_arena_id!(LocalTypeParamId); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ContainerId { diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index e00bd03d5..4c859e497 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -18,8 +18,8 @@ use crate::{ path::{Path, PathKind}, per_ns::PerNs, AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, - GenericDefId, GenericParamId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, - StaticId, StructId, TraitId, TypeAliasId, + GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, + StructId, TraitId, TypeAliasId, TypeParamId, }; #[derive(Debug, Clone, Default)] @@ -59,7 +59,7 @@ enum Scope { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum TypeNs { SelfType(ImplId), - GenericParam(GenericParamId), + GenericParam(TypeParamId), AdtId(AdtId), AdtSelfType(AdtId), // Yup, enum variants are added to the types ns, but any usage of variant as @@ -157,7 +157,7 @@ impl Resolver { if let Some(local_id) = params.find_by_name(first_name) { let idx = if path.segments.len() == 1 { None } else { Some(1) }; return Some(( - TypeNs::GenericParam(GenericParamId { local_id, parent: *def }), + TypeNs::GenericParam(TypeParamId { local_id, parent: *def }), idx, )); } @@ -252,7 +252,7 @@ impl Resolver { Scope::GenericParams { params, def } if n_segments > 1 => { if let Some(local_id) = params.find_by_name(first_name) { - let ty = TypeNs::GenericParam(GenericParamId { local_id, parent: *def }); + let ty = TypeNs::GenericParam(TypeParamId { local_id, parent: *def }); return Some(ResolveValueResult::Partial(ty, 1)); } } @@ -399,7 +399,7 @@ pub enum ScopeDef { PerNs(PerNs), ImplSelfType(ImplId), AdtSelfType(AdtId), - GenericParam(GenericParamId), + GenericParam(TypeParamId), Local(PatId), } @@ -431,10 +431,10 @@ impl Scope { } } Scope::GenericParams { params, def } => { - for (local_id, param) in params.params.iter() { + for (local_id, param) in params.types.iter() { f( param.name.clone(), - ScopeDef::GenericParam(GenericParamId { local_id, parent: *def }), + ScopeDef::GenericParam(TypeParamId { local_id, parent: *def }), ) } } @@ -481,7 +481,7 @@ impl Resolver { fn push_generic_params_scope(self, db: &impl DefDatabase, def: GenericDefId) -> Resolver { let params = db.generic_params(def); - if params.params.is_empty() { + if params.types.is_empty() { self } else { self.push_scope(Scope::GenericParams { def, params }) diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs index 936cfe25e..aeb211a91 100644 --- a/crates/ra_hir_ty/src/utils.rs +++ b/crates/ra_hir_ty/src/utils.rs @@ -5,10 +5,10 @@ use std::sync::Arc; use hir_def::{ adt::VariantData, db::DefDatabase, - generics::{GenericParamData, GenericParams}, + generics::{GenericParams, TypeParamData}, resolver::{HasResolver, TypeNs}, type_ref::TypeRef, - ContainerId, GenericDefId, GenericParamId, Lookup, TraitId, TypeAliasId, VariantId, + ContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId, }; use hir_expand::name::{self, Name}; @@ -96,23 +96,21 @@ pub(crate) struct Generics { } impl Generics { - pub(crate) fn iter<'a>(&'a self) -> impl Iterator + 'a { + pub(crate) fn iter<'a>(&'a self) -> impl Iterator + 'a { self.parent_generics .as_ref() .into_iter() - .flat_map(|it| it.params.params.iter()) - .chain(self.params.params.iter()) + .flat_map(|it| it.params.types.iter()) + .chain(self.params.types.iter()) .enumerate() .map(|(i, (_local_id, p))| (i as u32, p)) } - pub(crate) fn iter_parent<'a>( - &'a self, - ) -> impl Iterator + 'a { + pub(crate) fn iter_parent<'a>(&'a self) -> impl Iterator + 'a { self.parent_generics .as_ref() .into_iter() - .flat_map(|it| it.params.params.iter()) + .flat_map(|it| it.params.types.iter()) .enumerate() .map(|(i, (_local_id, p))| (i as u32, p)) } @@ -123,20 +121,20 @@ impl Generics { /// (total, parents, child) pub(crate) fn len_split(&self) -> (usize, usize, usize) { let parent = self.parent_generics.as_ref().map_or(0, |p| p.len()); - let child = self.params.params.len(); + let child = self.params.types.len(); (parent + child, parent, child) } - pub(crate) fn param_idx(&self, param: GenericParamId) -> u32 { + pub(crate) fn param_idx(&self, param: TypeParamId) -> u32 { self.find_param(param).0 } - pub(crate) fn param_name(&self, param: GenericParamId) -> Name { + pub(crate) fn param_name(&self, param: TypeParamId) -> Name { self.find_param(param).1.name.clone() } - fn find_param(&self, param: GenericParamId) -> (u32, &GenericParamData) { + fn find_param(&self, param: TypeParamId) -> (u32, &TypeParamData) { if param.parent == self.def { let (idx, (_local_id, data)) = self .params - .params + .types .iter() .enumerate() .find(|(_, (idx, _))| *idx == param.local_id) diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index e8c3d980f..6a6b49afd 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -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 { diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 64c0cbad4..1b968134d 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -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) { diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index d8185c688..d372ca758 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -138,7 +138,7 @@ fn hover_text_from_name_kind( *no_fallback = true; None } - GenericParam(_) | SelfType(_) => { + TypeParam(_) | SelfType(_) => { // FIXME: Hover for generic param None } diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 3e7bfd872..e3ecde50d 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -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 = { diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index ed98dbc13..c1f091ec0 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs @@ -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) => { diff --git a/crates/ra_ide/src/references/name_definition.rs b/crates/ra_ide/src/references/name_definition.rs index 10d3a2364..8c67c8863 100644 --- a/crates/ra_ide/src/references/name_definition.rs +++ b/crates/ra_ide/src/references/name_definition.rs @@ -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)] diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 79f11ea80..9dfbc8047 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -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; } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 20eefeb57..7ecb1a027 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -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" -- cgit v1.2.3