From 76202a2c7371a6930db7b83af75c0f5a8ae1d061 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 29 Jul 2020 19:22:15 +0200 Subject: Rename NomialDef -> AdtDef --- crates/ra_assists/src/handlers/generate_derive.rs | 4 +-- crates/ra_assists/src/handlers/generate_impl.rs | 2 +- crates/ra_ide/src/goto_implementation.rs | 10 +++--- crates/ra_syntax/src/ast/generated/nodes.rs | 38 +++++++++++------------ xtask/src/codegen/rust.ungram | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/ra_assists/src/handlers/generate_derive.rs b/crates/ra_assists/src/handlers/generate_derive.rs index 6ccf39900..90ece9fab 100644 --- a/crates/ra_assists/src/handlers/generate_derive.rs +++ b/crates/ra_assists/src/handlers/generate_derive.rs @@ -26,7 +26,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // ``` pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let cap = ctx.config.snippet_cap?; - let nominal = ctx.find_node_at_offset::()?; + let nominal = ctx.find_node_at_offset::()?; let node_start = derive_insertion_offset(&nominal)?; let target = nominal.syntax().text_range(); acc.add( @@ -58,7 +58,7 @@ pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option< } // Insert `derive` after doc comments. -fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option { +fn derive_insertion_offset(nominal: &ast::AdtDef) -> Option { let non_ws_child = nominal .syntax() .children_with_tokens() diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs index cbbac1d7f..42eb4defa 100644 --- a/crates/ra_assists/src/handlers/generate_impl.rs +++ b/crates/ra_assists/src/handlers/generate_impl.rs @@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // } // ``` pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { - let nominal = ctx.find_node_at_offset::()?; + let nominal = ctx.find_node_at_offset::()?; let name = nominal.name()?; let target = nominal.syntax().text_range(); acc.add( diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 3ee048f28..16a61d071 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -23,7 +23,7 @@ pub(crate) fn goto_implementation( let krate = sema.to_module_def(position.file_id)?.krate(); - if let Some(nominal_def) = find_node_at_offset::(&syntax, position.offset) { + if let Some(nominal_def) = find_node_at_offset::(&syntax, position.offset) { return Some(RangeInfo::new( nominal_def.syntax().text_range(), impls_for_def(&sema, &nominal_def, krate)?, @@ -40,13 +40,13 @@ pub(crate) fn goto_implementation( fn impls_for_def( sema: &Semantics, - node: &ast::NominalDef, + node: &ast::AdtDef, krate: Crate, ) -> Option> { let ty = match node { - ast::NominalDef::StructDef(def) => sema.to_def(def)?.ty(sema.db), - ast::NominalDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), - ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), + ast::AdtDef::StructDef(def) => sema.to_def(def)?.ty(sema.db), + ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), + ast::AdtDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), }; let impls = ImplDef::all_in_crate(sema.db, krate); diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index b2d108a7c..04a4d354c 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -1376,15 +1376,15 @@ impl ast::AttrsOwner for ExternItem {} impl ast::NameOwner for ExternItem {} impl ast::VisibilityOwner for ExternItem {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum NominalDef { +pub enum AdtDef { StructDef(StructDef), EnumDef(EnumDef), UnionDef(UnionDef), } -impl ast::AttrsOwner for NominalDef {} -impl ast::NameOwner for NominalDef {} -impl ast::TypeParamsOwner for NominalDef {} -impl ast::VisibilityOwner for NominalDef {} +impl ast::AttrsOwner for AdtDef {} +impl ast::NameOwner for AdtDef {} +impl ast::TypeParamsOwner for AdtDef {} +impl ast::VisibilityOwner for AdtDef {} impl AstNode for SourceFile { fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } fn cast(syntax: SyntaxNode) -> Option { @@ -3345,16 +3345,16 @@ impl AstNode for ExternItem { } } } -impl From for NominalDef { - fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } +impl From for AdtDef { + fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) } } -impl From for NominalDef { - fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) } +impl From for AdtDef { + fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } } -impl From for NominalDef { - fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) } +impl From for AdtDef { + fn from(node: UnionDef) -> AdtDef { AdtDef::UnionDef(node) } } -impl AstNode for NominalDef { +impl AstNode for AdtDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { STRUCT_DEF | ENUM_DEF | UNION_DEF => true, @@ -3363,18 +3363,18 @@ impl AstNode for NominalDef { } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }), - ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }), - UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }), + STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), + ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), + UNION_DEF => AdtDef::UnionDef(UnionDef { syntax }), _ => return None, }; Some(res) } fn syntax(&self) -> &SyntaxNode { match self { - NominalDef::StructDef(it) => &it.syntax, - NominalDef::EnumDef(it) => &it.syntax, - NominalDef::UnionDef(it) => &it.syntax, + AdtDef::StructDef(it) => &it.syntax, + AdtDef::EnumDef(it) => &it.syntax, + AdtDef::UnionDef(it) => &it.syntax, } } } @@ -3423,7 +3423,7 @@ impl std::fmt::Display for ExternItem { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for NominalDef { +impl std::fmt::Display for AdtDef { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 8a3eb7b29..b6ec5d5e7 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -426,7 +426,7 @@ ExternItemList = MetaItem = Path '=' AttrInput nested_meta_items:MetaItem* -NominalDef = +AdtDef = StructDef | EnumDef | UnionDef -- cgit v1.2.3