diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 29 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 2 |
3 files changed, 18 insertions, 17 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 2e958fa23..6ebe10ff6 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -262,9 +262,9 @@ impl ast::PathSegment { | |||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | impl ast::UseItem { | 265 | impl ast::Use { |
266 | #[must_use] | 266 | #[must_use] |
267 | pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { | 267 | pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use { |
268 | if let Some(old) = self.use_tree() { | 268 | if let Some(old) = self.use_tree() { |
269 | return self.replace_descendant(old, use_tree); | 269 | return self.replace_descendant(old, use_tree); |
270 | } | 270 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 9d8127a3d..be657699f 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -213,12 +213,12 @@ impl UnionDef { | |||
213 | } | 213 | } |
214 | } | 214 | } |
215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
216 | pub struct UseItem { | 216 | pub struct Use { |
217 | pub(crate) syntax: SyntaxNode, | 217 | pub(crate) syntax: SyntaxNode, |
218 | } | 218 | } |
219 | impl ast::AttrsOwner for UseItem {} | 219 | impl ast::AttrsOwner for Use {} |
220 | impl ast::VisibilityOwner for UseItem {} | 220 | impl ast::VisibilityOwner for Use {} |
221 | impl UseItem { | 221 | impl Use { |
222 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } | 222 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } |
223 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | 223 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } |
224 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 224 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
@@ -1283,7 +1283,7 @@ pub enum Item { | |||
1283 | TraitDef(TraitDef), | 1283 | TraitDef(TraitDef), |
1284 | TypeAliasDef(TypeAliasDef), | 1284 | TypeAliasDef(TypeAliasDef), |
1285 | UnionDef(UnionDef), | 1285 | UnionDef(UnionDef), |
1286 | UseItem(UseItem), | 1286 | Use(Use), |
1287 | } | 1287 | } |
1288 | impl ast::AttrsOwner for Item {} | 1288 | impl ast::AttrsOwner for Item {} |
1289 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1289 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1562,8 +1562,8 @@ impl AstNode for UnionDef { | |||
1562 | } | 1562 | } |
1563 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1563 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1564 | } | 1564 | } |
1565 | impl AstNode for UseItem { | 1565 | impl AstNode for Use { |
1566 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } | 1566 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE } |
1567 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1567 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1568 | if Self::can_cast(syntax.kind()) { | 1568 | if Self::can_cast(syntax.kind()) { |
1569 | Some(Self { syntax }) | 1569 | Some(Self { syntax }) |
@@ -2811,15 +2811,16 @@ impl From<TypeAliasDef> for Item { | |||
2811 | impl From<UnionDef> for Item { | 2811 | impl From<UnionDef> for Item { |
2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } |
2813 | } | 2813 | } |
2814 | impl From<UseItem> for Item { | 2814 | impl From<Use> for Item { |
2815 | fn from(node: UseItem) -> Item { Item::UseItem(node) } | 2815 | fn from(node: Use) -> Item { Item::Use(node) } |
2816 | } | 2816 | } |
2817 | impl AstNode for Item { | 2817 | impl AstNode for Item { |
2818 | fn can_cast(kind: SyntaxKind) -> bool { | 2818 | fn can_cast(kind: SyntaxKind) -> bool { |
2819 | match kind { | 2819 | match kind { |
2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL | 2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL |
2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | 2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { |
2822 | | USE_ITEM => true, | 2822 | true |
2823 | } | ||
2823 | _ => false, | 2824 | _ => false, |
2824 | } | 2825 | } |
2825 | } | 2826 | } |
@@ -2838,7 +2839,7 @@ impl AstNode for Item { | |||
2838 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2839 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), | 2840 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), |
2840 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2841 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), |
2841 | USE_ITEM => Item::UseItem(UseItem { syntax }), | 2842 | USE => Item::Use(Use { syntax }), |
2842 | _ => return None, | 2843 | _ => return None, |
2843 | }; | 2844 | }; |
2844 | Some(res) | 2845 | Some(res) |
@@ -2858,7 +2859,7 @@ impl AstNode for Item { | |||
2858 | Item::TraitDef(it) => &it.syntax, | 2859 | Item::TraitDef(it) => &it.syntax, |
2859 | Item::TypeAliasDef(it) => &it.syntax, | 2860 | Item::TypeAliasDef(it) => &it.syntax, |
2860 | Item::UnionDef(it) => &it.syntax, | 2861 | Item::UnionDef(it) => &it.syntax, |
2861 | Item::UseItem(it) => &it.syntax, | 2862 | Item::Use(it) => &it.syntax, |
2862 | } | 2863 | } |
2863 | } | 2864 | } |
2864 | } | 2865 | } |
@@ -3531,7 +3532,7 @@ impl std::fmt::Display for UnionDef { | |||
3531 | std::fmt::Display::fmt(self.syntax(), f) | 3532 | std::fmt::Display::fmt(self.syntax(), f) |
3532 | } | 3533 | } |
3533 | } | 3534 | } |
3534 | impl std::fmt::Display for UseItem { | 3535 | impl std::fmt::Display for Use { |
3535 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3536 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3536 | std::fmt::Display::fmt(self.syntax(), f) | 3537 | std::fmt::Display::fmt(self.syntax(), f) |
3537 | } | 3538 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 2b05ed2d4..0ff69bc2d 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -60,7 +60,7 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast:: | |||
60 | ast_from_text(&format!("use {{{}}};", use_trees)) | 60 | ast_from_text(&format!("use {{{}}};", use_trees)) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { | 63 | pub fn use_item(use_tree: ast::UseTree) -> ast::Use { |
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||