Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup!…
Browse files Browse the repository at this point in the history
… fixup! Rename GroupComponent et UniqueComponent into Block and Value

Fixes #19323: Be able to group reporting and methods so that we have clearer techniques and a better reporting
  • Loading branch information
VinceMacBuche committed Jul 2, 2021
1 parent aa41609 commit f16781f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions language/src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,11 +1386,11 @@ fn test_pstatement() {
vec![
(
map_res(penum_expression, "ubuntu ").unwrap().1,
vec![map_res(pstatement, "f().g()").unwrap().1]
map_res(pstatement, "f().g()").unwrap().1
),
(
map_res(penum_expression, "debian ").unwrap().1,
vec![map_res(pstatement, "a().b() ").unwrap().1]
map_res(pstatement, "a().b() ").unwrap().1
),
]
)
Expand Down
11 changes: 6 additions & 5 deletions language/src/technique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ pub struct MethodBlock {
id: String,
}
impl MethodBlock {
fn to_rudderlang(&self,context:&Vec<MethodBlock>, lib: &RudderlangLib) -> Result<String> {
fn to_rudderlang(&self, context:&Vec<&MethodBlock>, lib: &RudderlangLib) -> Result<String> {

&context.push(*self);
let mut newContext = context.clone();
newContext.push(self);
return self
.childs
.iter()
Expand Down Expand Up @@ -263,7 +264,7 @@ fn generate_id() -> String {
Uuid::new_v4().to_string()
}
impl MethodCall {
fn to_rudderlang(&self,context:&Vec<MethodBlock>, lib: &LanguageLib) -> Result<String> {
fn to_rudderlang(&self,context:&Vec<&MethodBlock>, lib: &LanguageLib) -> Result<String> {
let lib_method: LibMethod = lib.method_from_str(&self.method_name)?;

let (mut params, template_vars) = self.format_parameters(&lib_method)?;
Expand Down Expand Up @@ -296,7 +297,7 @@ impl MethodCall {
state_params.join(", ")
);
if self.condition != "any" {
call = format!("if {} => {}", self.format_condition(&context,&lib)?, call);
call = format!("if {} => {}", self.format_condition(context,&lib)?, call);
}

// only get original name, other aliases do not matter here
Expand Down Expand Up @@ -391,7 +392,7 @@ impl MethodCall {
}

// TODO parse content so interpolated variables are handled properly
fn format_condition(&self,context:&Vec<MethodBlock> , lib: &LanguageLib) -> Result<String> {
fn format_condition(&self,context:&Vec<&MethodBlock> , lib: &LanguageLib) -> Result<String> {
lazy_static! {
static ref CONDITION_RE: Regex = Regex::new(r"([\w${}.]+)").unwrap();
static ref ANY_RE: Regex = Regex::new(r"(any\.)").unwrap();
Expand Down

0 comments on commit f16781f

Please sign in to comment.