diff --git a/src/template_parser.rs b/src/template_parser.rs index 235dcacae..6ef3d0afc 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -753,7 +753,7 @@ fn split_email(email: &str) -> (&str, Option<&str>) { fn build_method_call<'a, I: 'a>( method: &MethodCallNode, - build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { match build_expression(&method.object, build_keyword)? { Expression::Property(PropertyAndLabels(property, mut labels)) => { @@ -802,7 +802,7 @@ fn chain_properties<'a, I: 'a, J: 'a, O: 'a>( fn build_string_method<'a, I: 'a>( self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let property = match function.name { "contains" => { @@ -831,7 +831,7 @@ fn build_string_method<'a, I: 'a>( fn build_boolean_method<'a, I: 'a>( _self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { Err(TemplateParseError::no_such_method("Boolean", function)) } @@ -839,7 +839,7 @@ fn build_boolean_method<'a, I: 'a>( fn build_integer_method<'a, I: 'a>( _self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { Err(TemplateParseError::no_such_method("Integer", function)) } @@ -847,7 +847,7 @@ fn build_integer_method<'a, I: 'a>( fn build_commit_or_change_id_method<'a, I: 'a>( self_property: impl TemplateProperty> + 'a, function: &FunctionCallNode, - build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let parse_optional_integer = |function| -> Result, TemplateParseError> { let ([], [len_node]) = expect_arguments(function)?; @@ -893,7 +893,7 @@ fn build_commit_or_change_id_method<'a, I: 'a>( fn build_shortest_id_prefix_method<'a, I: 'a>( self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let property = match function.name { "prefix" => { @@ -923,7 +923,7 @@ fn build_shortest_id_prefix_method<'a, I: 'a>( fn build_signature_method<'a, I: 'a>( self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let property = match function.name { "name" => { @@ -965,7 +965,7 @@ fn build_signature_method<'a, I: 'a>( fn build_timestamp_method<'a, I: 'a>( self_property: impl TemplateProperty + 'a, function: &FunctionCallNode, - _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + _build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let property = match function.name { "ago" => { @@ -982,7 +982,7 @@ fn build_timestamp_method<'a, I: 'a>( fn build_global_function<'a, C: 'a>( function: &FunctionCallNode, - build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { let expression = match function.name { "label" => { @@ -1034,7 +1034,7 @@ fn build_commit_keyword<'a>( workspace_id: &WorkspaceId, name: &str, span: pest::Span, -) -> TemplateParseResult> { +) -> TemplateParseResult> { fn wrap_fn<'a, O>( f: impl Fn(&Commit) -> O + 'a, ) -> Box + 'a> { @@ -1074,17 +1074,19 @@ fn build_commit_keyword<'a>( })), _ => return Err(TemplateParseError::no_such_keyword(name, span)), }; - Ok(PropertyAndLabels(property, vec![name.to_owned()])) + Ok(property) } /// Builds template evaluation tree from AST nodes. fn build_expression<'a, C: 'a>( node: &ExpressionNode, - build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, + build_keyword: &impl Fn(&str, pest::Span) -> TemplateParseResult>, ) -> TemplateParseResult> { match &node.kind { ExpressionKind::Identifier(name) => { - Ok(Expression::Property(build_keyword(name, node.span)?)) + let property = build_keyword(name, node.span)?; + let labels = vec![(*name).to_owned()]; + Ok(Expression::Property(PropertyAndLabels(property, labels))) } ExpressionKind::Integer(value) => { let term = PropertyAndLabels(Property::Integer(Box::new(Literal(*value))), vec![]);