aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-29 18:40:56 +0100
committerGitHub <[email protected]>2020-07-29 18:40:56 +0100
commit17126b9827dcec89bbe07add455a4ad893db58fa (patch)
tree9b355311e2b9261c125f2c3a2a0f205b9d8e5da7
parent2dfda0b984c45946b9a4148bd848350deac544f2 (diff)
parent76202a2c7371a6930db7b83af75c0f5a8ae1d061 (diff)
Merge #5573
5573: Rename NomialDef -> AdtDef r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_assists/src/handlers/generate_derive.rs4
-rw-r--r--crates/ra_assists/src/handlers/generate_impl.rs2
-rw-r--r--crates/ra_ide/src/goto_implementation.rs10
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs38
-rw-r--r--xtask/src/codegen/rust.ungram2
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};
26// ``` 26// ```
27pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 27pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
28 let cap = ctx.config.snippet_cap?; 28 let cap = ctx.config.snippet_cap?;
29 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; 29 let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?;
30 let node_start = derive_insertion_offset(&nominal)?; 30 let node_start = derive_insertion_offset(&nominal)?;
31 let target = nominal.syntax().text_range(); 31 let target = nominal.syntax().text_range();
32 acc.add( 32 acc.add(
@@ -58,7 +58,7 @@ pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<
58} 58}
59 59
60// Insert `derive` after doc comments. 60// Insert `derive` after doc comments.
61fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextSize> { 61fn derive_insertion_offset(nominal: &ast::AdtDef) -> Option<TextSize> {
62 let non_ws_child = nominal 62 let non_ws_child = nominal
63 .syntax() 63 .syntax()
64 .children_with_tokens() 64 .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};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; 26 let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?;
27 let name = nominal.name()?; 27 let name = nominal.name()?;
28 let target = nominal.syntax().text_range(); 28 let target = nominal.syntax().text_range();
29 acc.add( 29 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(
23 23
24 let krate = sema.to_module_def(position.file_id)?.krate(); 24 let krate = sema.to_module_def(position.file_id)?.krate();
25 25
26 if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) { 26 if let Some(nominal_def) = find_node_at_offset::<ast::AdtDef>(&syntax, position.offset) {
27 return Some(RangeInfo::new( 27 return Some(RangeInfo::new(
28 nominal_def.syntax().text_range(), 28 nominal_def.syntax().text_range(),
29 impls_for_def(&sema, &nominal_def, krate)?, 29 impls_for_def(&sema, &nominal_def, krate)?,
@@ -40,13 +40,13 @@ pub(crate) fn goto_implementation(
40 40
41fn impls_for_def( 41fn impls_for_def(
42 sema: &Semantics<RootDatabase>, 42 sema: &Semantics<RootDatabase>,
43 node: &ast::NominalDef, 43 node: &ast::AdtDef,
44 krate: Crate, 44 krate: Crate,
45) -> Option<Vec<NavigationTarget>> { 45) -> Option<Vec<NavigationTarget>> {
46 let ty = match node { 46 let ty = match node {
47 ast::NominalDef::StructDef(def) => sema.to_def(def)?.ty(sema.db), 47 ast::AdtDef::StructDef(def) => sema.to_def(def)?.ty(sema.db),
48 ast::NominalDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), 48 ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db),
49 ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), 49 ast::AdtDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db),
50 }; 50 };
51 51
52 let impls = ImplDef::all_in_crate(sema.db, krate); 52 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 {}
1376impl ast::NameOwner for ExternItem {} 1376impl ast::NameOwner for ExternItem {}
1377impl ast::VisibilityOwner for ExternItem {} 1377impl ast::VisibilityOwner for ExternItem {}
1378#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1378#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1379pub enum NominalDef { 1379pub enum AdtDef {
1380 StructDef(StructDef), 1380 StructDef(StructDef),
1381 EnumDef(EnumDef), 1381 EnumDef(EnumDef),
1382 UnionDef(UnionDef), 1382 UnionDef(UnionDef),
1383} 1383}
1384impl ast::AttrsOwner for NominalDef {} 1384impl ast::AttrsOwner for AdtDef {}
1385impl ast::NameOwner for NominalDef {} 1385impl ast::NameOwner for AdtDef {}
1386impl ast::TypeParamsOwner for NominalDef {} 1386impl ast::TypeParamsOwner for AdtDef {}
1387impl ast::VisibilityOwner for NominalDef {} 1387impl ast::VisibilityOwner for AdtDef {}
1388impl AstNode for SourceFile { 1388impl AstNode for SourceFile {
1389 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1389 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
1390 fn cast(syntax: SyntaxNode) -> Option<Self> { 1390 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3345,16 +3345,16 @@ impl AstNode for ExternItem {
3345 } 3345 }
3346 } 3346 }
3347} 3347}
3348impl From<StructDef> for NominalDef { 3348impl From<StructDef> for AdtDef {
3349 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } 3349 fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) }
3350} 3350}
3351impl From<EnumDef> for NominalDef { 3351impl From<EnumDef> for AdtDef {
3352 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) } 3352 fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) }
3353} 3353}
3354impl From<UnionDef> for NominalDef { 3354impl From<UnionDef> for AdtDef {
3355 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) } 3355 fn from(node: UnionDef) -> AdtDef { AdtDef::UnionDef(node) }
3356} 3356}
3357impl AstNode for NominalDef { 3357impl AstNode for AdtDef {
3358 fn can_cast(kind: SyntaxKind) -> bool { 3358 fn can_cast(kind: SyntaxKind) -> bool {
3359 match kind { 3359 match kind {
3360 STRUCT_DEF | ENUM_DEF | UNION_DEF => true, 3360 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
@@ -3363,18 +3363,18 @@ impl AstNode for NominalDef {
3363 } 3363 }
3364 fn cast(syntax: SyntaxNode) -> Option<Self> { 3364 fn cast(syntax: SyntaxNode) -> Option<Self> {
3365 let res = match syntax.kind() { 3365 let res = match syntax.kind() {
3366 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }), 3366 STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }),
3367 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }), 3367 ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }),
3368 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }), 3368 UNION_DEF => AdtDef::UnionDef(UnionDef { syntax }),
3369 _ => return None, 3369 _ => return None,
3370 }; 3370 };
3371 Some(res) 3371 Some(res)
3372 } 3372 }
3373 fn syntax(&self) -> &SyntaxNode { 3373 fn syntax(&self) -> &SyntaxNode {
3374 match self { 3374 match self {
3375 NominalDef::StructDef(it) => &it.syntax, 3375 AdtDef::StructDef(it) => &it.syntax,
3376 NominalDef::EnumDef(it) => &it.syntax, 3376 AdtDef::EnumDef(it) => &it.syntax,
3377 NominalDef::UnionDef(it) => &it.syntax, 3377 AdtDef::UnionDef(it) => &it.syntax,
3378 } 3378 }
3379 } 3379 }
3380} 3380}
@@ -3423,7 +3423,7 @@ impl std::fmt::Display for ExternItem {
3423 std::fmt::Display::fmt(self.syntax(), f) 3423 std::fmt::Display::fmt(self.syntax(), f)
3424 } 3424 }
3425} 3425}
3426impl std::fmt::Display for NominalDef { 3426impl std::fmt::Display for AdtDef {
3427 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3427 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3428 std::fmt::Display::fmt(self.syntax(), f) 3428 std::fmt::Display::fmt(self.syntax(), f)
3429 } 3429 }
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 =
426MetaItem = 426MetaItem =
427 Path '=' AttrInput nested_meta_items:MetaItem* 427 Path '=' AttrInput nested_meta_items:MetaItem*
428 428
429NominalDef = 429AdtDef =
430 StructDef 430 StructDef
431| EnumDef 431| EnumDef
432| UnionDef 432| UnionDef