From 1766aae145c6925a33e427f2fe6ef2a56c301665 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:56:53 +0200 Subject: Rename EnumVariant -> Variant --- crates/ra_hir_def/src/adt.rs | 4 ++-- crates/ra_hir_def/src/child_by_source.rs | 2 +- crates/ra_hir_def/src/item_tree/lower.rs | 4 ++-- crates/ra_hir_def/src/keys.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index df98ded62..231c1dfab 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -112,7 +112,7 @@ impl EnumData { impl HasChildSource for EnumId { type ChildId = LocalEnumVariantId; - type Value = ast::EnumVariant; + type Value = ast::Variant; fn child_source(&self, db: &dyn DefDatabase) -> InFile> { let src = self.lookup(db).source(db); let mut trace = Trace::new_for_map(); @@ -123,7 +123,7 @@ impl HasChildSource for EnumId { fn lower_enum( db: &dyn DefDatabase, - trace: &mut Trace, + trace: &mut Trace, ast: &InFile, module_id: ModuleId, ) { diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs index a885ec96d..dcb00a1d9 100644 --- a/crates/ra_hir_def/src/child_by_source.rs +++ b/crates/ra_hir_def/src/child_by_source.rs @@ -162,7 +162,7 @@ impl ChildBySource for EnumId { let arena_map = arena_map.as_ref(); for (local_id, source) in arena_map.value.iter() { let id = EnumVariantId { parent: *self, local_id }; - res[keys::ENUM_VARIANT].insert(arena_map.with_value(source.clone()), id) + res[keys::VARIANT].insert(arena_map.with_value(source.clone()), id) } res diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index da7238416..6d963c852 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -259,7 +259,7 @@ impl Ctx { Some(id(self.data().enums.alloc(res))) } - fn lower_variants(&mut self, variants: &ast::EnumVariantList) -> IdRange { + fn lower_variants(&mut self, variants: &ast::VariantList) -> IdRange { let start = self.next_variant_idx(); for variant in variants.variants() { if let Some(data) = self.lower_variant(&variant) { @@ -271,7 +271,7 @@ impl Ctx { IdRange::new(start..end) } - fn lower_variant(&mut self, variant: &ast::EnumVariant) -> Option { + fn lower_variant(&mut self, variant: &ast::Variant) -> Option { let name = variant.name()?.as_name(); let fields = self.lower_fields(&variant.kind()); let res = Variant { name, fields }; diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index 2695e8c24..c2a03dfed 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -24,7 +24,7 @@ pub const STRUCT: Key = Key::new(); pub const UNION: Key = Key::new(); pub const ENUM: Key = Key::new(); -pub const ENUM_VARIANT: Key = Key::new(); +pub const VARIANT: Key = Key::new(); pub const TUPLE_FIELD: Key = Key::new(); pub const RECORD_FIELD: Key = Key::new(); pub const TYPE_PARAM: Key = Key::new(); -- cgit v1.2.3 From 3cd4112bdc924c132cb0eab9d064511a215421ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:02:20 +0200 Subject: Finalize const&static grammar --- crates/ra_hir_def/src/body/lower.rs | 4 ++-- crates/ra_hir_def/src/item_tree.rs | 8 ++++---- crates/ra_hir_def/src/item_tree/lower.rs | 16 ++++++++-------- crates/ra_hir_def/src/item_tree/tests.rs | 2 +- crates/ra_hir_def/src/keys.rs | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 105299f70..4a26e6397 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -641,14 +641,14 @@ impl ExprCollector<'_> { def.name(), ) } - ast::Item::ConstDef(def) => { + ast::Item::Const(def) => { let id = self.find_inner_item(&def)?; ( ConstLoc { container: container.into(), id }.intern(self.db).into(), def.name(), ) } - ast::Item::StaticDef(def) => { + ast::Item::Static(def) => { let id = self.find_inner_item(&def)?; (StaticLoc { container, id }.intern(self.db).into(), def.name()) } diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 24ad41187..c478a9909 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -417,8 +417,8 @@ mod_items! { Struct in structs -> ast::Struct, Union in unions -> ast::Union, Enum in enums -> ast::Enum, - Const in consts -> ast::ConstDef, - Static in statics -> ast::StaticDef, + Const in consts -> ast::Const, + Static in statics -> ast::Static, Trait in traits -> ast::TraitDef, Impl in impls -> ast::ImplDef, TypeAlias in type_aliases -> ast::TypeAlias, @@ -552,7 +552,7 @@ pub struct Const { pub name: Option, pub visibility: RawVisibilityId, pub type_ref: TypeRef, - pub ast_id: FileAstId, + pub ast_id: FileAstId, } #[derive(Debug, Clone, Eq, PartialEq)] @@ -561,7 +561,7 @@ pub struct Static { pub visibility: RawVisibilityId, pub mutable: bool, pub type_ref: TypeRef, - pub ast_id: FileAstId, + pub ast_id: FileAstId, } #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 6d963c852..a94548e5d 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -83,8 +83,8 @@ impl Ctx { | ast::Item::Enum(_) | ast::Item::Fn(_) | ast::Item::TypeAlias(_) - | ast::Item::ConstDef(_) - | ast::Item::StaticDef(_) + | ast::Item::Const(_) + | ast::Item::Static(_) | ast::Item::MacroCall(_) => { // Skip this if we're already collecting inner items. We'll descend into all nodes // already. @@ -108,8 +108,8 @@ impl Ctx { ast::Item::Enum(ast) => self.lower_enum(ast).map(Into::into), ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into), ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into), - ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into), - ast::Item::ConstDef(ast) => Some(self.lower_const(ast).into()), + ast::Item::Static(ast) => self.lower_static(ast).map(Into::into), + ast::Item::Const(ast) => Some(self.lower_const(ast).into()), ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into), ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into), @@ -160,7 +160,7 @@ impl Ctx { match item { ast::AssocItem::Fn(ast) => self.lower_function(ast).map(Into::into), ast::AssocItem::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into), - ast::AssocItem::ConstDef(ast) => Some(self.lower_const(ast).into()), + ast::AssocItem::Const(ast) => Some(self.lower_const(ast).into()), ast::AssocItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), } } @@ -368,7 +368,7 @@ impl Ctx { Some(id(self.data().type_aliases.alloc(res))) } - fn lower_static(&mut self, static_: &ast::StaticDef) -> Option> { + fn lower_static(&mut self, static_: &ast::Static) -> Option> { let name = static_.name()?.as_name(); let type_ref = self.lower_type_ref_opt(static_.ascribed_type()); let visibility = self.lower_visibility(static_); @@ -378,7 +378,7 @@ impl Ctx { Some(id(self.data().statics.alloc(res))) } - fn lower_const(&mut self, konst: &ast::ConstDef) -> FileItemTreeId { + fn lower_const(&mut self, konst: &ast::Const) -> FileItemTreeId { let name = konst.name().map(|it| it.as_name()); let type_ref = self.lower_type_ref_opt(konst.ascribed_type()); let visibility = self.lower_visibility(konst); @@ -553,7 +553,7 @@ impl Ctx { self.data().functions[func.index].is_unsafe = true; func.into() } - ast::ExternItem::StaticDef(ast) => { + ast::ExternItem::Static(ast) => { let statik = self.lower_static(&ast)?; statik.into() } diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index bf3474c51..e61ce58bc 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -238,7 +238,7 @@ fn smoke() { > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::(8) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] - > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::(9) } + > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::(9) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(10) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index c2a03dfed..f75e3bb50 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -15,8 +15,8 @@ use crate::{ pub type Key = crate::dyn_map::Key, V, AstPtrPolicy>; pub const FUNCTION: Key = Key::new(); -pub const CONST: Key = Key::new(); -pub const STATIC: Key = Key::new(); +pub const CONST: Key = Key::new(); +pub const STATIC: Key = Key::new(); pub const TYPE_ALIAS: Key = Key::new(); pub const IMPL: Key = Key::new(); pub const TRAIT: Key = Key::new(); -- cgit v1.2.3