mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:23 +00:00
Move ExprCall
's NeedsParentheses
impl into expr_call.rs
(#6309)
Accidental move.
This commit is contained in:
parent
74e734e962
commit
c75e8a8dab
2 changed files with 15 additions and 15 deletions
|
@ -1,6 +1,8 @@
|
||||||
use ruff_formatter::write;
|
use ruff_formatter::write;
|
||||||
|
use ruff_python_ast::node::AnyNodeRef;
|
||||||
use ruff_python_ast::ExprCall;
|
use ruff_python_ast::ExprCall;
|
||||||
|
|
||||||
|
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::FormatNodeRule;
|
use crate::FormatNodeRule;
|
||||||
|
|
||||||
|
@ -18,3 +20,13 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
|
||||||
write!(f, [func.format(), arguments.format()])
|
write!(f, [func.format(), arguments.format()])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NeedsParentheses for ExprCall {
|
||||||
|
fn needs_parentheses(
|
||||||
|
&self,
|
||||||
|
_parent: AnyNodeRef,
|
||||||
|
context: &PyFormatContext,
|
||||||
|
) -> OptionalParentheses {
|
||||||
|
self.func.needs_parentheses(self.into(), context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use ruff_formatter::write;
|
use ruff_formatter::write;
|
||||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
use ruff_python_ast::node::AstNode;
|
||||||
use ruff_python_ast::{Arguments, Expr, ExprCall, Ranged};
|
use ruff_python_ast::{Arguments, Expr, Ranged};
|
||||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
||||||
use ruff_text_size::{TextRange, TextSize};
|
use ruff_text_size::{TextRange, TextSize};
|
||||||
|
|
||||||
use crate::builders::empty_parenthesized_with_dangling_comments;
|
use crate::builders::empty_parenthesized_with_dangling_comments;
|
||||||
use crate::comments::trailing_comments;
|
use crate::comments::trailing_comments;
|
||||||
use crate::expression::expr_generator_exp::GeneratorExpParentheses;
|
use crate::expression::expr_generator_exp::GeneratorExpParentheses;
|
||||||
use crate::expression::parentheses::{
|
use crate::expression::parentheses::{parenthesized, Parentheses};
|
||||||
parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
|
|
||||||
};
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::FormatNodeRule;
|
use crate::FormatNodeRule;
|
||||||
|
|
||||||
|
@ -116,16 +114,6 @@ impl FormatNodeRule<Arguments> for FormatArguments {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NeedsParentheses for ExprCall {
|
|
||||||
fn needs_parentheses(
|
|
||||||
&self,
|
|
||||||
_parent: AnyNodeRef,
|
|
||||||
context: &PyFormatContext,
|
|
||||||
) -> OptionalParentheses {
|
|
||||||
self.func.needs_parentheses(self.into(), context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_single_argument_parenthesized(argument: &Expr, call_end: TextSize, source: &str) -> bool {
|
fn is_single_argument_parenthesized(argument: &Expr, call_end: TextSize, source: &str) -> bool {
|
||||||
let mut has_seen_r_paren = false;
|
let mut has_seen_r_paren = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue