mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Rename GenericParam -> TypeParam
We don't have LifetimeParam yet, but they are planned!
This commit is contained in:
parent
f4f8b81474
commit
88c5b1282a
18 changed files with 77 additions and 79 deletions
|
@ -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),
|
||||
|
|
|
@ -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<ast::TraitDef, ast::TypeParam>;
|
||||
fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> {
|
||||
let child_source = self.id.parent.child_source(db);
|
||||
|
|
|
@ -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<ast::TypeParam>) -> Option<Self> {
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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<Resolver> {
|
||||
|
@ -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<PathResolution> {
|
||||
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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue