From 55a29982c014a57867a540ccc0161ef983cfcf46 Mon Sep 17 00:00:00 2001 From: veetaha Date: Tue, 12 May 2020 23:33:56 +0300 Subject: Revert "Remove MacroStmts as per edwin0cheng" (cc @edwin0cheng) and add a fixme to document it. This reverts commit 7a49165f5d5c8186edd04f874eae8a98e39d3df6. MacroStmts ast node is not used by itself, but it pertains to SyntaxNodeKind MACRO_STMTS that is used by ra_paser, so even tho the node itself is not used, it is better to keep it with a FIXME to actually add a doc comment when it becomes useful. --- crates/ra_syntax/src/ast/generated/nodes.rs | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 7b236cd52..5dad028c7 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -2491,6 +2491,22 @@ pub struct MacroItems { } impl ast::ModuleItemOwner for MacroItems {} impl MacroItems {} +/// FIXME: (@edwin0cheng) add some documentation here. As per the writing +/// of this comment this ast node is not used. +/// +/// ``` +/// // FIXME: example here +/// ``` +/// +/// [Reference](https://doc.rust-lang.org/reference/macros.html) +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct MacroStmts { + pub(crate) syntax: SyntaxNode, +} +impl MacroStmts { + pub fn statements(&self) -> AstChildren { support::children(&self.syntax) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } +} /// List of items in an extern block. /// /// ``` @@ -4047,6 +4063,17 @@ impl AstNode for MacroItems { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for MacroStmts { + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for ExternItemList { fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } fn cast(syntax: SyntaxNode) -> Option { @@ -5479,6 +5506,11 @@ impl std::fmt::Display for MacroItems { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for MacroStmts { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for ExternItemList { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) -- cgit v1.2.3