From ce1b34fd59a6145a4bb5682d672c846e101725d4 Mon Sep 17 00:00:00 2001 From: Michael Chesser Date: Tue, 7 Jan 2020 09:29:03 +1030 Subject: Improve const generics parsing - Handle const generics type args - Fix issue with const generic as first parameter in trait impl --- crates/ra_syntax/src/ast/generated.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 2eb4b14d2..33d5578e7 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -3114,6 +3114,9 @@ impl TypeArgList { pub fn assoc_type_args(&self) -> AstChildren { AstChildren::new(&self.syntax) } + pub fn const_arg(&self) -> AstChildren { + AstChildren::new(&self.syntax) + } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TypeArg { @@ -3196,6 +3199,36 @@ impl AstNode for LifetimeArg { } impl LifetimeArg {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ConstArg { + pub(crate) syntax: SyntaxNode, +} +impl AstNode for ConstArg { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + CONST_ARG => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl ConstArg { + pub fn literal(&self) -> Option { + AstChildren::new(&self.syntax).next() + } + pub fn block_expr(&self) -> Option { + AstChildren::new(&self.syntax).next() + } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct MacroItems { pub(crate) syntax: SyntaxNode, } -- cgit v1.2.3