mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-11 06:42:47 +00:00
templater: fix span of method call expression
Spotted while experimenting with field expression. This span is unused, so no test output changes.
This commit is contained in:
parent
e3825495e3
commit
08e66fb7d4
1 changed files with 16 additions and 1 deletions
|
@ -333,7 +333,7 @@ fn parse_term_node(pair: Pair<Rule>) -> TemplateParseResult<ExpressionNode> {
|
|||
};
|
||||
inner.try_fold(primary, |object, chain| {
|
||||
assert_eq!(chain.as_rule(), Rule::function);
|
||||
let span = chain.as_span();
|
||||
let span = object.span.start_pos().span(&chain.as_span().end_pos());
|
||||
let method = MethodCallNode {
|
||||
object: Box::new(object),
|
||||
function: parse_function_call_node(chain)?,
|
||||
|
@ -846,6 +846,21 @@ mod tests {
|
|||
assert!(parse_template(r#" label("",,"") "#).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_method_call_syntax() {
|
||||
assert_eq!(
|
||||
parse_normalized("x.f().g()").unwrap(),
|
||||
parse_normalized("(x.f()).g()").unwrap(),
|
||||
);
|
||||
|
||||
// Expression span
|
||||
assert_eq!(parse_template(" x.f() ").unwrap().span.as_str(), "x.f()");
|
||||
assert_eq!(
|
||||
parse_template(" x.f().g() ").unwrap().span.as_str(),
|
||||
"x.f().g()",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lambda_syntax() {
|
||||
fn unwrap_lambda(node: ExpressionNode<'_>) -> LambdaNode<'_> {
|
||||
|
|
Loading…
Reference in a new issue