From 6cd2131cafd29ae17442efbcce652bd447576f27 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 11:58:41 +0200 Subject: Rename Rename --- crates/ra_syntax/src/ast/edit.rs | 2 +- crates/ra_syntax/src/ast/generated/nodes.rs | 16 ++++++++-------- crates/ra_syntax/src/ast/make.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 01a310f66..99f4726bc 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -318,7 +318,7 @@ impl ast::UseTree { None => return self.clone(), }; let use_tree = - make::use_tree(suffix, self.use_tree_list(), self.alias(), self.star_token().is_some()); + make::use_tree(suffix, self.use_tree_list(), self.rename(), self.star_token().is_some()); let nested = make::use_tree_list(iter::once(use_tree)); return make::use_tree(prefix.clone(), Some(nested), None, false); diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index fbf3b457a..01e8111b0 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -75,7 +75,7 @@ impl ExternCrateItem { pub fn crate_token(&self) -> Option { support::token(&self.syntax, T![crate]) } pub fn name_ref(&self) -> Option { support::child(&self.syntax) } pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } - pub fn alias(&self) -> Option { support::child(&self.syntax) } + pub fn rename(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -1178,7 +1178,7 @@ impl UseTree { pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn star_token(&self) -> Option { support::token(&self.syntax, T![*]) } pub fn use_tree_list(&self) -> Option { support::child(&self.syntax) } - pub fn alias(&self) -> Option { support::child(&self.syntax) } + pub fn rename(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct UseTreeList { @@ -1190,11 +1190,11 @@ impl UseTreeList { pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Alias { +pub struct Rename { pub(crate) syntax: SyntaxNode, } -impl ast::NameOwner for Alias {} -impl Alias { +impl ast::NameOwner for Rename {} +impl Rename { pub fn as_token(&self) -> Option { support::token(&self.syntax, T![as]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -2683,8 +2683,8 @@ impl AstNode for UseTreeList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Alias { - fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } +impl AstNode for Rename { + fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -4040,7 +4040,7 @@ impl std::fmt::Display for UseTreeList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Alias { +impl std::fmt::Display for Rename { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 192c610f1..2b05ed2d4 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -37,7 +37,7 @@ fn path_from_text(text: &str) -> ast::Path { pub fn use_tree( path: ast::Path, use_tree_list: Option, - alias: Option, + alias: Option, add_star: bool, ) -> ast::UseTree { let mut buf = "use ".to_string(); -- cgit v1.2.3 From 026e4e6af1e58843f3535f6e0f5365d0c2529e4e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 12:01:14 +0200 Subject: Update tests --- crates/ra_syntax/src/ast/edit.rs | 8 ++++++-- crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast | 8 ++++---- crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast | 4 ++-- crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast | 6 +++--- 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 99f4726bc..2e958fa23 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -317,8 +317,12 @@ impl ast::UseTree { Some(it) => it, None => return self.clone(), }; - let use_tree = - make::use_tree(suffix, self.use_tree_list(), self.rename(), self.star_token().is_some()); + let use_tree = make::use_tree( + suffix, + self.use_tree_list(), + self.rename(), + self.star_token().is_some(), + ); let nested = make::use_tree_list(iter::once(use_tree)); return make::use_tree(prefix.clone(), Some(nested), None, false); diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast index f0e09d40d..8e9061e1d 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast @@ -13,7 +13,7 @@ SOURCE_FILE@0..198 NAME_REF@10..14 IDENT@10..14 "path" WHITESPACE@14..15 " " - ALIAS@15..27 + RENAME@15..27 AS_KW@15..17 "as" WHITESPACE@17..18 " " NAME@18..27 @@ -43,7 +43,7 @@ SOURCE_FILE@0..198 NAME_REF@49..53 IDENT@49..53 "path" WHITESPACE@53..54 " " - ALIAS@54..72 + RENAME@54..72 AS_KW@54..56 "as" WHITESPACE@56..57 " " NAME@57..72 @@ -61,7 +61,7 @@ SOURCE_FILE@0..198 NAME_REF@86..90 IDENT@86..90 "path" WHITESPACE@90..91 " " - ALIAS@91..108 + RENAME@91..108 AS_KW@91..93 "as" WHITESPACE@93..94 " " NAME@94..108 @@ -130,7 +130,7 @@ SOURCE_FILE@0..198 NAME_REF@186..191 IDENT@186..191 "Trait" WHITESPACE@191..192 " " - ALIAS@192..196 + RENAME@192..196 AS_KW@192..194 "as" WHITESPACE@194..195 " " UNDERSCORE@195..196 "_" diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast index 271486605..948c4ddb3 100644 --- a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast +++ b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast @@ -16,7 +16,7 @@ SOURCE_FILE@0..69 NAME_REF@31..34 IDENT@31..34 "foo" WHITESPACE@34..35 " " - ALIAS@35..41 + RENAME@35..41 AS_KW@35..37 "as" WHITESPACE@37..38 " " NAME@38..41 @@ -30,7 +30,7 @@ SOURCE_FILE@0..69 WHITESPACE@55..56 " " SELF_KW@56..60 "self" WHITESPACE@60..61 " " - ALIAS@61..67 + RENAME@61..67 AS_KW@61..63 "as" WHITESPACE@63..64 " " NAME@64..67 diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast index 09e0050f0..cdddb4214 100644 --- a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast +++ b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast @@ -8,7 +8,7 @@ SOURCE_FILE@0..55 NAME_REF@4..7 IDENT@4..7 "foo" WHITESPACE@7..8 " " - ALIAS@8..14 + RENAME@8..14 AS_KW@8..10 "as" WHITESPACE@10..11 " " NAME@11..14 @@ -32,7 +32,7 @@ SOURCE_FILE@0..55 NAME_REF@26..27 IDENT@26..27 "a" WHITESPACE@27..28 " " - ALIAS@28..32 + RENAME@28..32 AS_KW@28..30 "as" WHITESPACE@30..31 " " NAME@31..32 @@ -55,7 +55,7 @@ SOURCE_FILE@0..55 NAME_REF@44..47 IDENT@44..47 "foo" WHITESPACE@47..48 " " - ALIAS@48..52 + RENAME@48..52 AS_KW@48..50 "as" WHITESPACE@50..51 " " NAME@51..52 -- cgit v1.2.3