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 +++++----- 5 files changed, 23 insertions(+), 23 deletions(-) (limited to 'crates/ra_hir') 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 }) -- cgit v1.2.3