From 7721accebf5e2c39bd4cb984346b11b72c12ba56 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 25 Aug 2020 10:57:51 +0200 Subject: Cleanup invert-if * stick to trivial factory functions in make * compress the logic for inverting Option/Result --- crates/syntax/src/ast/make.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/syntax/src/ast') diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 7958721e2..7ba625990 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -7,7 +7,7 @@ use itertools::Itertools; use stdx::format_to; -use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxText, SyntaxToken}; +use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; pub fn name(text: &str) -> ast::Name { ast_from_text(&format!("mod {};", text)) @@ -137,11 +137,8 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { expr_from_text(&format!("{}{}", f, arg_list)) } -pub fn expr_method_call(text: &str, caller: F) -> Option -where - F: FnOnce() -> Option, -{ - try_expr_from_text(&format!("{}.{}()", caller()?, text)) +pub fn expr_method_call(receiver: ast::Expr, method: &str, arg_list: ast::ArgList) -> ast::Expr { + expr_from_text(&format!("{}.{}{}", receiver, method, arg_list)) } fn expr_from_text(text: &str) -> ast::Expr { ast_from_text(&format!("const C: () = {};", text)) -- cgit v1.2.3