mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Revert "Remove MacroStmts as per edwin0cheng" (cc @edwin0cheng) and add a fixme to document it.
This reverts commit 7a49165f5d
.
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.
This commit is contained in:
parent
24b27abf9f
commit
55a29982c0
2 changed files with 45 additions and 0 deletions
|
@ -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<Stmt> { support::children(&self.syntax) }
|
||||
pub fn expr(&self) -> Option<Expr> { 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<Self> {
|
||||
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<Self> {
|
||||
|
@ -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)
|
||||
|
|
|
@ -2016,6 +2016,19 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
|||
/// [Reference](https://doc.rust-lang.org/reference/macros.html)
|
||||
struct MacroItems: ModuleItemOwner { }
|
||||
|
||||
/// 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)
|
||||
struct MacroStmts {
|
||||
statements: [Stmt],
|
||||
Expr,
|
||||
}
|
||||
|
||||
/// List of items in an extern block.
|
||||
///
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue