aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/utils/insert_use.rs2
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs2
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs2
-rw-r--r--crates/ra_ide_db/src/defs.rs2
-rw-r--r--crates/ra_parser/src/grammar.rs2
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs2
-rw-r--r--crates/ra_syntax/src/ast/edit.rs8
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs16
-rw-r--r--crates/ra_syntax/src/ast/make.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast6
12 files changed, 30 insertions, 26 deletions
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs
index 8c4f33e59..c05027eff 100644
--- a/crates/ra_assists/src/utils/insert_use.rs
+++ b/crates/ra_assists/src/utils/insert_use.rs
@@ -215,7 +215,7 @@ fn walk_use_tree_for_best_action(
215 let prev_len = current_path_segments.len(); 215 let prev_len = current_path_segments.len();
216 216
217 let tree_list = current_use_tree.use_tree_list(); 217 let tree_list = current_use_tree.use_tree_list();
218 let alias = current_use_tree.alias(); 218 let alias = current_use_tree.rename();
219 219
220 let path = match current_use_tree.path() { 220 let path = match current_use_tree.path() {
221 Some(path) => path, 221 Some(path) => path,
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 4fc21a642..6c58c6378 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -501,7 +501,7 @@ impl Ctx {
501 extern_crate: &ast::ExternCrateItem, 501 extern_crate: &ast::ExternCrateItem,
502 ) -> Option<FileItemTreeId<ExternCrate>> { 502 ) -> Option<FileItemTreeId<ExternCrate>> {
503 let path = ModPath::from_name_ref(&extern_crate.name_ref()?); 503 let path = ModPath::from_name_ref(&extern_crate.name_ref()?);
504 let alias = extern_crate.alias().map(|a| { 504 let alias = extern_crate.rename().map(|a| {
505 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) 505 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
506 }); 506 });
507 let visibility = self.lower_visibility(extern_crate); 507 let visibility = self.lower_visibility(extern_crate);
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index 7cc655487..794be45e8 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -31,7 +31,7 @@ pub(crate) fn lower_use_tree(
31 lower_use_tree(prefix.clone(), child_tree, hygiene, cb); 31 lower_use_tree(prefix.clone(), child_tree, hygiene, cb);
32 } 32 }
33 } else { 33 } else {
34 let alias = tree.alias().map(|a| { 34 let alias = tree.rename().map(|a| {
35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) 35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
36 }); 36 });
37 let is_glob = tree.star_token().is_some(); 37 let is_glob = tree.star_token().is_some();
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index f391a8e43..1464c5f2a 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -119,7 +119,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
119 119
120 match_ast! { 120 match_ast! {
121 match parent { 121 match parent {
122 ast::Alias(it) => { 122 ast::Rename(it) => {
123 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; 123 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?;
124 let path = use_tree.path()?; 124 let path = use_tree.path()?;
125 let path_segment = path.segment()?; 125 let path_segment = path.segment()?;
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index 3350e23b9..7dfac2813 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -224,7 +224,7 @@ fn opt_alias(p: &mut Parser) {
224 if !p.eat(T![_]) { 224 if !p.eat(T![_]) {
225 name(p); 225 name(p);
226 } 226 }
227 m.complete(p, ALIAS); 227 m.complete(p, RENAME);
228 } 228 }
229} 229}
230 230
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 56dadc6af..f14b60b65 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -221,7 +221,7 @@ pub enum SyntaxKind {
221 PATH, 221 PATH,
222 PATH_SEGMENT, 222 PATH_SEGMENT,
223 LITERAL, 223 LITERAL,
224 ALIAS, 224 RENAME,
225 VISIBILITY, 225 VISIBILITY,
226 WHERE_CLAUSE, 226 WHERE_CLAUSE,
227 WHERE_PRED, 227 WHERE_PRED,
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 01a310f66..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 {
317 Some(it) => it, 317 Some(it) => it,
318 None => return self.clone(), 318 None => return self.clone(),
319 }; 319 };
320 let use_tree = 320 let use_tree = make::use_tree(
321 make::use_tree(suffix, self.use_tree_list(), self.alias(), self.star_token().is_some()); 321 suffix,
322 self.use_tree_list(),
323 self.rename(),
324 self.star_token().is_some(),
325 );
322 let nested = make::use_tree_list(iter::once(use_tree)); 326 let nested = make::use_tree_list(iter::once(use_tree));
323 return make::use_tree(prefix.clone(), Some(nested), None, false); 327 return make::use_tree(prefix.clone(), Some(nested), None, false);
324 328
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 {
75 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } 75 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
76 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 76 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
77 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 77 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
78 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 78 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
79 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 79 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
80} 80}
81#[derive(Debug, Clone, PartialEq, Eq, Hash)] 81#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1178,7 +1178,7 @@ impl UseTree {
1178 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 1178 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1179 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 1179 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
1180 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } 1180 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
1181 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 1181 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
1182} 1182}
1183#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1184pub struct UseTreeList { 1184pub struct UseTreeList {
@@ -1190,11 +1190,11 @@ impl UseTreeList {
1190 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1190 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1191} 1191}
1192#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1192#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1193pub struct Alias { 1193pub struct Rename {
1194 pub(crate) syntax: SyntaxNode, 1194 pub(crate) syntax: SyntaxNode,
1195} 1195}
1196impl ast::NameOwner for Alias {} 1196impl ast::NameOwner for Rename {}
1197impl Alias { 1197impl Rename {
1198 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 1198 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1199} 1199}
1200#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2683,8 +2683,8 @@ impl AstNode for UseTreeList {
2683 } 2683 }
2684 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2684 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2685} 2685}
2686impl AstNode for Alias { 2686impl AstNode for Rename {
2687 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } 2687 fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME }
2688 fn cast(syntax: SyntaxNode) -> Option<Self> { 2688 fn cast(syntax: SyntaxNode) -> Option<Self> {
2689 if Self::can_cast(syntax.kind()) { 2689 if Self::can_cast(syntax.kind()) {
2690 Some(Self { syntax }) 2690 Some(Self { syntax })
@@ -4040,7 +4040,7 @@ impl std::fmt::Display for UseTreeList {
4040 std::fmt::Display::fmt(self.syntax(), f) 4040 std::fmt::Display::fmt(self.syntax(), f)
4041 } 4041 }
4042} 4042}
4043impl std::fmt::Display for Alias { 4043impl std::fmt::Display for Rename {
4044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4045 std::fmt::Display::fmt(self.syntax(), f) 4045 std::fmt::Display::fmt(self.syntax(), f)
4046 } 4046 }
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 {
37pub fn use_tree( 37pub fn use_tree(
38 path: ast::Path, 38 path: ast::Path,
39 use_tree_list: Option<ast::UseTreeList>, 39 use_tree_list: Option<ast::UseTreeList>,
40 alias: Option<ast::Alias>, 40 alias: Option<ast::Rename>,
41 add_star: bool, 41 add_star: bool,
42) -> ast::UseTree { 42) -> ast::UseTree {
43 let mut buf = "use ".to_string(); 43 let mut buf = "use ".to_string();
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 @@ [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "path" 14 [email protected] "path"
15 [email protected] " " 15 [email protected] " "
16 ALIAS@15..27 16 RENAME@15..27
17 [email protected] "as" 17 [email protected] "as"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 [email protected]
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] 43 [email protected]
44 [email protected] "path" 44 [email protected] "path"
45 [email protected] " " 45 [email protected] " "
46 ALIAS@54..72 46 RENAME@54..72
47 [email protected] "as" 47 [email protected] "as"
48 [email protected] " " 48 [email protected] " "
49 [email protected] 49 [email protected]
@@ -61,7 +61,7 @@ [email protected]
61 [email protected] 61 [email protected]
62 [email protected] "path" 62 [email protected] "path"
63 [email protected] " " 63 [email protected] " "
64 ALIAS@91..108 64 RENAME@91..108
65 [email protected] "as" 65 [email protected] "as"
66 [email protected] " " 66 [email protected] " "
67 [email protected] 67 [email protected]
@@ -130,7 +130,7 @@ [email protected]
130 [email protected] 130 [email protected]
131 [email protected] "Trait" 131 [email protected] "Trait"
132 [email protected] " " 132 [email protected] " "
133 ALIAS@192..196 133 RENAME@192..196
134 [email protected] "as" 134 [email protected] "as"
135 [email protected] " " 135 [email protected] " "
136 [email protected] "_" 136 [email protected] "_"
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 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "foo" 17 [email protected] "foo"
18 [email protected] " " 18 [email protected] " "
19 ALIAS@35..41 19 RENAME@35..41
20 [email protected] "as" 20 [email protected] "as"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] " " 30 [email protected] " "
31 [email protected] "self" 31 [email protected] "self"
32 [email protected] " " 32 [email protected] " "
33 ALIAS@61..67 33 RENAME@61..67
34 [email protected] "as" 34 [email protected] "as"
35 [email protected] " " 35 [email protected] " "
36 [email protected] 36 [email protected]
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 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "foo" 9 [email protected] "foo"
10 [email protected] " " 10 [email protected] " "
11 ALIAS@8..14 11 RENAME@8..14
12 [email protected] "as" 12 [email protected] "as"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -32,7 +32,7 @@ [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "a" 33 [email protected] "a"
34 [email protected] " " 34 [email protected] " "
35 ALIAS@28..32 35 RENAME@28..32
36 [email protected] "as" 36 [email protected] "as"
37 [email protected] " " 37 [email protected] " "
38 [email protected] 38 [email protected]
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "foo" 56 [email protected] "foo"
57 [email protected] " " 57 [email protected] " "
58 ALIAS@48..52 58 RENAME@48..52
59 [email protected] "as" 59 [email protected] "as"
60 [email protected] " " 60 [email protected] " "
61 [email protected] 61 [email protected]