From 58480b9190d8851abf7f634820188e33efed286d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 3 Sep 2018 02:01:43 +0300 Subject: method call scope --- crates/libsyntax2/src/ast/generated.rs | 10 ++++++---- crates/libsyntax2/src/ast/mod.rs | 6 ++++++ crates/libsyntax2/src/grammar.ron | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index bdee635ae..11306a835 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -200,12 +200,10 @@ impl<'a> AstNode<'a> for CallExpr<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } +impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} impl<'a> CallExpr<'a> {pub fn expr(self) -> Option> { super::child_opt(self) } -pub fn arg_list(self) -> Option> { - super::child_opt(self) - } } // CastExpr @@ -934,7 +932,11 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } -impl<'a> MethodCallExpr<'a> {} +impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} +impl<'a> MethodCallExpr<'a> {pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // Module #[derive(Debug, Clone, Copy)] diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 49e283f5e..274996171 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs @@ -26,6 +26,12 @@ pub trait LoopBodyOwner<'a>: AstNode<'a> { } } +pub trait ArgListOwner<'a>: AstNode<'a> { + fn arg_list(self) -> Option> { + child_opt(self) + } +} + pub trait TypeParamsOwner<'a>: AstNode<'a> { fn type_param_list(self) -> Option> { child_opt(self) diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 798725f7e..683623a5d 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -388,10 +388,14 @@ Grammar( "NamedFieldList": (), "NamedField": (), "CallExpr": ( - options: [ "Expr", "ArgList" ] + traits: ["ArgListOwner"], + options: [ "Expr" ], + ), + "MethodCallExpr": ( + traits: ["ArgListOwner"], + options: [ "Expr" ], ), "IndexExpr": (), - "MethodCallExpr": (), "FieldExpr": (), "TryExpr": (), "CastExpr": (), -- cgit v1.2.3