diff --git a/src/models/default_configs.rs b/src/models/default_configs.rs index e090349ee..c0d595008 100644 --- a/src/models/default_configs.rs +++ b/src/models/default_configs.rs @@ -47,6 +47,10 @@ pub fn default_substitutions() -> Vec<(String, String)> { vec![] } +pub fn default_substitutions_int() -> Vec<(String, u8)> { + vec![] +} + pub fn default_delete_file_if_empty() -> bool { true } @@ -111,6 +115,10 @@ pub fn default_replace_idx() -> u8 { u8::MAX } +pub fn default_replace_idx_of() -> String { + String::new() +} + pub fn default_replace() -> String { String::new() } diff --git a/src/models/edit.rs b/src/models/edit.rs index 60b86a610..3cf466910 100644 --- a/src/models/edit.rs +++ b/src/models/edit.rs @@ -11,7 +11,7 @@ Copyright (c) 2023 Uber Technologies, Inc. limitations under the License. */ -use std::fmt; +use std::{fmt, collections::HashMap}; use colored::Colorize; use getset::{Getters, MutGetters}; @@ -65,7 +65,6 @@ impl Edit { } #[cfg(test)] pub(crate) fn delete_range(code: &str, replacement_range: Range) -> Self { - use std::collections::HashMap; Self { p_match: Match::new( code[replacement_range.start_byte..replacement_range.end_byte].to_string(), @@ -145,7 +144,7 @@ impl SourceCodeUnit { .get_matches(rule, rule_store, node, recursive) .first() .map(|p_match| { - let replacement_string = rule.replace().instantiate(p_match.matches()); + let replacement_string = rule.replace().instantiate(p_match.matches(), &HashMap::new()); let edit = Edit::new( p_match.clone(), replacement_string, diff --git a/src/models/filter.rs b/src/models/filter.rs index 9fca56d51..00d2bbe20 100644 --- a/src/models/filter.rs +++ b/src/models/filter.rs @@ -276,21 +276,21 @@ pub use filter; impl Instantiate for Filter { /// Create a new filter from `self` by updating the all queries (i.e., `enclosing_node`, `not_enclosing_node`, `contains`, `not_contains`) based on the substitutions. - fn instantiate(&self, substitutions_for_holes: &HashMap) -> Filter { + fn instantiate(&self, substitutions_for_holes: &HashMap, int_substitutions: &HashMap) -> Filter { Filter { - enclosing_node: self.enclosing_node().instantiate(substitutions_for_holes), + enclosing_node: self.enclosing_node().instantiate(substitutions_for_holes, int_substitutions), outermost_enclosing_node: self .outermost_enclosing_node() - .instantiate(substitutions_for_holes), + .instantiate(substitutions_for_holes, int_substitutions), not_enclosing_node: self .not_enclosing_node() - .instantiate(substitutions_for_holes), + .instantiate(substitutions_for_holes, int_substitutions), not_contains: self .not_contains() .iter() - .map(|x| x.instantiate(substitutions_for_holes)) + .map(|x| x.instantiate(substitutions_for_holes, int_substitutions)) .collect_vec(), - contains: self.contains().instantiate(substitutions_for_holes), + contains: self.contains().instantiate(substitutions_for_holes, int_substitutions), at_least: self.at_least, at_most: self.at_most, child_count: self.child_count, @@ -310,7 +310,7 @@ impl SourceCodeUnit { rule .filters() .iter() - .all(|filter| self._check(filter.clone(), node, rule_store, &updated_substitutions)) + .all(|filter| self._check(filter.clone(), node, rule_store, &updated_substitutions, &HashMap::new())) } /// Determines if the given `node` meets the conditions specified by the `filter`. @@ -328,10 +328,10 @@ impl SourceCodeUnit { /// If these conditions hold, the function returns true, indicating the `node` meets the `filter`'s criteria. fn _check( &self, filter: Filter, node: Node, rule_store: &mut RuleStore, - substitutions: &HashMap, + substitutions: &HashMap, int_substitutions: &HashMap ) -> bool { let mut node_to_check = node; - let instantiated_filter = filter.instantiate(substitutions); + let instantiated_filter = filter.instantiate(substitutions, int_substitutions); if *filter.child_count() != default_child_count() { return node.named_child_count() == (*filter.child_count() as usize); diff --git a/src/models/piranha_arguments.rs b/src/models/piranha_arguments.rs index acc3e6882..b15e2bbf5 100644 --- a/src/models/piranha_arguments.rs +++ b/src/models/piranha_arguments.rs @@ -18,13 +18,13 @@ use super::{ default_dry_run, default_exclude, default_global_tag_prefix, default_include, default_number_of_ancestors_in_parent_scope, default_path_to_codebase, default_path_to_configurations, default_path_to_output_summaries, default_piranha_language, - default_rule_graph, default_substitutions, GO, JAVA, KOTLIN, PYTHON, SWIFT, TSX, TYPESCRIPT, + default_rule_graph, default_substitutions, default_substitutions_int, GO, JAVA, KOTLIN, PYTHON, SWIFT, TSX, TYPESCRIPT, }, language::PiranhaLanguage, rule_graph::{read_user_config_files, RuleGraph, RuleGraphBuilder}, source_code_unit::SourceCodeUnit, }; -use crate::utilities::{parse_glob_pattern, parse_key_val}; +use crate::utilities::{parse_glob_pattern, parse_key_val, parse_key_val_int}; use clap::builder::TypedValueParser; use clap::Parser; use derive_builder::Builder; @@ -70,12 +70,18 @@ pub struct PiranhaArguments { #[clap(short = 't', long, default_value_t = default_code_snippet())] code_snippet: String, - /// These substitutions instantiate the initial set of rules. + /// These string substitutions instantiate the initial set of rules. /// Usage : -s stale_flag_name=SOME_FLAG -s namespace=SOME_NS1 #[builder(default = "default_substitutions()")] #[clap(short = 's', value_parser = parse_key_val)] substitutions: Vec<(String, String)>, + /// These integer substitutions instantiate the initial set of rules. + /// Usage : -i stale_flag_name=SOME_FLAG -s namespace=SOME_NS1 + #[builder(default = "default_substitutions_int()")] + #[clap(short = 'i', value_parser = parse_key_val_int)] + substitutions_int: Vec<(String, u8)>, + /// Directory containing the configuration files - `rules.toml` and `edges.toml` (optional) #[get = "pub"] #[builder(default = "default_path_to_configurations()")] @@ -178,7 +184,7 @@ impl PiranhaArguments { #[new] fn py_new( language: String, path_to_codebase: Option, include: Option>, - exclude: Option>, substitutions: Option<&PyDict>, + exclude: Option>, substitutions: Option<&PyDict>, substitutions_int: Option<&PyDict>, path_to_configurations: Option, rule_graph: Option, code_snippet: Option, dry_run: Option, cleanup_comments: Option, cleanup_comments_buffer: Option, number_of_ancestors_in_parent_scope: Option, @@ -192,6 +198,12 @@ impl PiranhaArguments { .collect_vec() }); + let subs_int: Vec<(String, u8)> = substitutions_int.map_or(vec![], |s| { + s.iter() + .map(|(k, v)| (k.to_string(), v.to_string().parse().unwrap())) + .collect_vec() + }); + let rg = rule_graph.unwrap_or_else(|| RuleGraphBuilder::default().build()); PiranhaArgumentsBuilder::default() .path_to_codebase(path_to_codebase.unwrap_or_else(default_path_to_codebase)) @@ -214,6 +226,7 @@ impl PiranhaArguments { .code_snippet(code_snippet.unwrap_or_else(default_code_snippet)) .language(PiranhaLanguage::from(language.as_str())) .substitutions(subs) + .substitutions_int(subs_int) .dry_run(dry_run.unwrap_or_else(default_dry_run)) .cleanup_comments(cleanup_comments.unwrap_or_else(default_cleanup_comments)) .cleanup_comments_buffer( @@ -244,6 +257,7 @@ impl PiranhaArguments { PiranhaArgumentsBuilder::default() .path_to_codebase(p.path_to_codebase().to_string()) .substitutions(p.substitutions.clone()) + .substitutions_int(p.substitutions_int.clone()) .language(p.language().clone()) .path_to_configurations(p.path_to_configurations().to_string()) .path_to_output_summary(p.path_to_output_summary().clone()) @@ -260,6 +274,10 @@ impl PiranhaArguments { pub(crate) fn input_substitutions(&self) -> HashMap { self.substitutions.iter().cloned().collect() } + + pub(crate) fn input_int_substitutions(&self) -> HashMap { + self.substitutions_int.iter().cloned().collect() + } } impl PiranhaArgumentsBuilder { diff --git a/src/models/rule.rs b/src/models/rule.rs index a7bc1fa68..038cdef3f 100644 --- a/src/models/rule.rs +++ b/src/models/rule.rs @@ -24,7 +24,8 @@ use crate::utilities::{gen_py_str_methods, tree_sitter_utilities::TSQuery, Insta use super::{ default_configs::{ default_filters, default_groups, default_holes, default_is_seed_rule, default_query, - default_replace, default_replace_idx, default_replace_node, default_rule_name, + default_replace, default_replace_idx, default_replace_idx_of, default_replace_node, + default_rule_name, }, filter::Filter, Validator, @@ -62,6 +63,12 @@ pub struct Rule { #[get = "pub"] #[pyo3(get)] replace_idx: u8, + /// The ith (i is the int value corresponding to the tag provided) child of node corresponding to the replace_node tag will be replaced + #[builder(default = "default_replace_idx_of()")] + #[serde(default = "default_replace_idx_of")] + #[get = "pub"] + #[pyo3(get)] + replace_idx_of: String, /// Replacement pattern #[builder(default = "default_replace()")] #[serde(default = "default_replace")] @@ -134,6 +141,7 @@ macro_rules! piranha_rule { $(, query =$query: expr)? $(, replace_node = $replace_node:expr)? $(, replace_idx = $replace_idx:expr)? + $(, replace_idx_of = $replace_idx_of:expr)? $(, replace = $replace:expr)? $(, holes = [$($hole: expr)*])? $(, is_seed_rule = $is_seed_rule:expr)? @@ -145,6 +153,7 @@ macro_rules! piranha_rule { $(.query($crate::utilities::tree_sitter_utilities::TSQuery::new($query.to_string())))? $(.replace_node($replace_node.to_string()))? $(.replace_idx($replace_idx.to_string()))? + $(.replace_idx_of($replace_idx_of.to_string()))? $(.replace($replace.to_string()))? $(.holes(std::collections::HashSet::from([$($hole.to_string(),)*])))? $(.groups(std::collections::HashSet::from([$($group_name.to_string(),)*])))? @@ -158,8 +167,8 @@ impl Rule { #[new] fn py_new( name: String, query: Option, replace: Option, replace_idx: Option, - replace_node: Option, holes: Option>, groups: Option>, - filters: Option>, is_seed_rule: Option, + replace_idx_of: Option, replace_node: Option, holes: Option>, + groups: Option>, filters: Option>, is_seed_rule: Option, ) -> Self { let mut rule_builder = RuleBuilder::default(); @@ -176,6 +185,10 @@ impl Rule { rule_builder.replace_idx(replace_idx); } + if let Some(replace_idx_of) = replace_idx_of { + rule_builder.replace_idx_of(replace_idx_of); + } + if let Some(replace_node) = replace_node { rule_builder.replace_node(replace_node); } @@ -223,7 +236,9 @@ pub(crate) struct InstantiatedRule { } impl InstantiatedRule { - pub(crate) fn new(rule: &Rule, substitutions: &HashMap) -> Self { + pub(crate) fn new( + rule: &Rule, substitutions: &HashMap, int_substitutions: &HashMap, + ) -> Self { let substitutions_for_holes: HashMap = rule .holes() .iter() @@ -236,7 +251,7 @@ impl InstantiatedRule { panic!("{}", format!( "Could not instantiate the rule {rule:?} with substitutions {substitutions_for_holes:?}").red()); } InstantiatedRule { - rule: rule.instantiate(&substitutions_for_holes), + rule: rule.instantiate(&substitutions_for_holes, int_substitutions), substitutions: substitutions_for_holes, } } @@ -280,11 +295,25 @@ impl Instantiate for Rule { /// Create a new query from `self` by updating the `query` and `replace` based on the substitutions. /// This functions assumes that each hole in the rule can be substituted. /// i.e. It assumes that `substitutions_for_holes` is exhaustive and complete - fn instantiate(&self, substitutions_for_holes: &HashMap) -> Rule { + fn instantiate( + &self, substitutions_for_holes: &HashMap, + int_substitutions: &HashMap, + ) -> Rule { let updated_rule = self.clone(); Rule { - query: updated_rule.query().instantiate(substitutions_for_holes), - replace: updated_rule.replace().instantiate(substitutions_for_holes), + query: updated_rule + .query() + .instantiate(substitutions_for_holes, int_substitutions), + replace: updated_rule + .replace() + .instantiate(substitutions_for_holes, int_substitutions), + replace_idx: if *updated_rule.replace_idx_of() != default_replace_idx_of() { + *int_substitutions + .get(updated_rule.replace_idx_of()) + .unwrap() + } else { + default_replace_idx() + }, ..updated_rule } } diff --git a/src/models/rule_graph.rs b/src/models/rule_graph.rs index 63dc80876..fb97fba0a 100644 --- a/src/models/rule_graph.rs +++ b/src/models/rule_graph.rs @@ -183,7 +183,7 @@ impl RuleGraph { // Group the next rules based on the scope next_rules.collect( String::from(&scope), - InstantiatedRule::new(to_rule_name, tag_matches), + InstantiatedRule::new(to_rule_name, tag_matches, &HashMap::new()), ); } } diff --git a/src/models/rule_store.rs b/src/models/rule_store.rs index 44bd66d7e..ad8f933b3 100644 --- a/src/models/rule_store.rs +++ b/src/models/rule_store.rs @@ -55,7 +55,11 @@ impl RuleStore { for rule in args.rule_graph().rules().clone() { if *rule.is_seed_rule() { - rule_store.add_to_global_rules(&InstantiatedRule::new(&rule, &args.input_substitutions())); + rule_store.add_to_global_rules(&InstantiatedRule::new( + &rule, + &args.input_substitutions(), + &args.input_int_substitutions(), + )); } } trace!("Rule Store {}", format!("{rule_store:#?}")); diff --git a/src/models/scopes.rs b/src/models/scopes.rs index 459fcf6bf..b90916559 100644 --- a/src/models/scopes.rs +++ b/src/models/scopes.rs @@ -11,6 +11,8 @@ Copyright (c) 2023 Uber Technologies, Inc. limitations under the License. */ +use std::collections::HashMap; + use derive_builder::Builder; use getset::Getters; use log::trace; @@ -73,7 +75,7 @@ impl SourceCodeUnit { ) { // Generate the scope query for the specific context by substituting the // the tags with code snippets appropriately in the `generator` query. - return m.scope().instantiate(p_match.matches()); + return m.scope().instantiate(p_match.matches(), &HashMap::new()); } } if let Some(parent) = changed_node.parent() { diff --git a/src/models/unit_tests/rule_test.rs b/src/models/unit_tests/rule_test.rs index 28d72e80c..34e584689 100644 --- a/src/models/unit_tests/rule_test.rs +++ b/src/models/unit_tests/rule_test.rs @@ -48,7 +48,7 @@ fn test_rule_try_instantiate_positive() { (String::from("variable_name"), String::from("foobar")), (String::from("@a.lhs"), String::from("something")), // Should not substitute, since it `a.lhs` is not in `rule.holes` ]); - let instantiated_rule = InstantiatedRule::new(&rule, &substitutions); + let instantiated_rule = InstantiatedRule::new(&rule, &substitutions, &HashMap::new()); assert!(eq_without_whitespace( instantiated_rule.query().get_query().as_str(), "(((assignment_expression left: (_) @a.lhs right: (_) @a.rhs) @abc) (#eq? @a.lhs \"foobar\"))" @@ -69,7 +69,7 @@ fn test_rule_try_instantiate_negative() { let substitutions: HashMap = HashMap::from([ (String::from("@a.lhs"), String::from("something")), // Should not substitute, since it `a.lhs` is not in `rule.holes` ]); - let _ = InstantiatedRule::new(&rule, &substitutions); + let _ = InstantiatedRule::new(&rule, &substitutions, &HashMap::new()); } /// Positive tests for `rule.get_edit` method for given rule and input source code. @@ -100,7 +100,7 @@ fn test_get_edit_positive_recursive() { } ] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(),&HashMap::new()); let source_code = "class Test { public void foobar(){ boolean isFlagTreated = true; @@ -170,7 +170,7 @@ fn test_get_edit_negative_recursive() { } }"; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let mut rule_store = RuleStore::default(); let args = PiranhaArgumentsBuilder::default() @@ -207,7 +207,7 @@ fn test_get_edit_for_context_positive() { replace_node = "binary_expression", replace = "" }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class A { boolean f = something && true; @@ -247,7 +247,7 @@ fn test_get_edit_for_context_negative() { replace_node = "binary_expression", replace = "" }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class A { boolean f = true; boolean x = something && true; @@ -290,7 +290,7 @@ fn run_test_satisfies_filters_not_enclosing_node( replace= "", filters= [filter,] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class Test { public void foobar(){ if (isFlagTreated) { diff --git a/src/models/unit_tests/source_code_unit_test.rs b/src/models/unit_tests/source_code_unit_test.rs index cf1cfa3a3..899d17177 100644 --- a/src/models/unit_tests/source_code_unit_test.rs +++ b/src/models/unit_tests/source_code_unit_test.rs @@ -140,7 +140,7 @@ fn run_test_satisfies_filters( )", filters= [filter,] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class Test { public void foobar(){ boolean isFlagTreated = true; @@ -301,7 +301,7 @@ fn test_satisfies_filters_not_contains_positive() { }] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(),&HashMap::new()); let source_code = "class Test { public void foobar(){ boolean isFlagTreated = true; @@ -366,7 +366,7 @@ fn test_satisfies_filters_not_contains_negative() { )",] }] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class Test { public void foobar(){ boolean isFlagTreated = true; @@ -424,7 +424,7 @@ fn test_satisfies_filters_child_count() { , child_count = 3 }] }; - let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new()); + let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new(), &HashMap::new()); let rule_neg = piranha_rule! { name= "test", @@ -440,7 +440,7 @@ fn test_satisfies_filters_child_count() { , child_count = 2 }] }; - let rule_neg = InstantiatedRule::new(&rule_neg, &HashMap::new()); + let rule_neg = InstantiatedRule::new(&rule_neg, &HashMap::new(), &HashMap::new()); let source_code = "class Test { public void foobar(){ @@ -494,7 +494,7 @@ fn test_satisfies_filters_sibling_count() { , sibling_count = 3 }] }; - let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new()); + let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new(), &HashMap::new()); let rule_neg = piranha_rule! { name= "test", @@ -511,7 +511,7 @@ fn test_satisfies_filters_sibling_count() { , sibling_count = 2 }] }; - let rule_neg = InstantiatedRule::new(&rule_neg, &HashMap::new()); + let rule_neg = InstantiatedRule::new(&rule_neg, &HashMap::new(),&HashMap::new()); let source_code = "class Test { public void foobar(){ @@ -561,7 +561,7 @@ fn run_test_satisfies_filters_without_enclosing( )", filters= [filter,] }; - let rule = InstantiatedRule::new(&_rule, &HashMap::new()); + let rule = InstantiatedRule::new(&_rule, &HashMap::new(), &HashMap::new()); let source_code = "class Test { public void foobar(){ boolean isFlagTreated = true; @@ -645,7 +645,7 @@ fn test_satisfies_outermost_enclosing_node() { , contains = "((method_invocation name: (_) @mname) @mi (#eq? @mname \"foobar\"))" }] }; - let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new()); + let rule_positive = InstantiatedRule::new(&rule_positive, &HashMap::new(), &HashMap::new()); let rule_negative = piranha_rule! { name= "test", @@ -658,7 +658,7 @@ fn test_satisfies_outermost_enclosing_node() { , not_contains = ["((method_invocation name: (_) @mname) @mi (#eq? @mname \"foobar\"))",] }] }; - let rule_negative = InstantiatedRule::new(&rule_negative, &HashMap::new()); + let rule_negative = InstantiatedRule::new(&rule_negative, &HashMap::new(), &HashMap::new()); let source_code = "class OuterClass { diff --git a/src/tests/test_piranha_python.rs b/src/tests/test_piranha_python.rs index 4d2b980bd..e16c554f0 100644 --- a/src/tests/test_piranha_python.rs +++ b/src/tests/test_piranha_python.rs @@ -44,7 +44,8 @@ fn test_delete_modify_str_literal_from_list_via_cli() { .arg("--dry-run") .args(["-s", "str_literal=dependency2"]) .args(["-s", "str_to_replace=dependency1"]) - .args(["-s", "str_replacement=dependency1_1"]); + .args(["-s", "str_replacement=dependency1_1"]) + .args(["-i", "foo=1"]); cmd.assert().success(); let content = read_file(&temp_file).unwrap(); diff --git a/src/utilities/mod.rs b/src/utilities/mod.rs index 5bea6db40..18ceb6e59 100644 --- a/src/utilities/mod.rs +++ b/src/utilities/mod.rs @@ -101,6 +101,18 @@ pub(crate) fn parse_key_val( Ok((s[..pos].parse()?, s[pos + 1..].parse()?)) } +/// Parse a single key-value pair +/// I have literally copy pasted this method from here +/// https://github.com/clap-rs/clap/blob/master/examples/typed-derive.rs#L48 +pub(crate) fn parse_key_val_int( + s: &str, +) -> Result<(String, u8), Box> { + let pos = s + .find('=') + .ok_or_else(|| format!("invalid KEY=value: no `=` found in `{s}`"))?; + Ok((s[..pos].parse()?, s[pos + 1..].parse()?)) +} + pub(crate) fn parse_glob_pattern( s: &str, ) -> Result> { @@ -157,11 +169,11 @@ pub(crate) trait Instantiate { /// /// * `input_string` : the string to be transformed /// * `substitutions` : a map between tree-sitter tag and the replacement string - fn instantiate(&self, substitutions: &HashMap) -> Self; + fn instantiate(&self, substitutions: &HashMap, int_substitutions_for_holes: &HashMap) -> Self; } impl Instantiate for String { - fn instantiate(&self, substitutions: &HashMap) -> Self { + fn instantiate(&self, substitutions: &HashMap, _: &HashMap) -> Self { let mut output = self.to_string(); for (tag, substitute) in substitutions { // Before replacing the key, it is transformed to a tree-sitter tag by adding `@` as prefix @@ -173,12 +185,12 @@ impl Instantiate for String { } impl Instantiate for TSQuery { - fn instantiate(&self, substitutions: &HashMap) -> Self { + fn instantiate(&self, substitutions: &HashMap, int_substitutions: &HashMap) -> Self { let substitutions = substitutions .iter() .map(|(k, v)| (k.to_string(), v.replace('\n', "\\n"))) .collect(); - TSQuery::new(self.get_query().instantiate(&substitutions)) + TSQuery::new(self.get_query().instantiate(&substitutions, int_substitutions)) } } diff --git a/src/utilities/unit_tests/tree_sitter_utilities_test.rs b/src/utilities/unit_tests/tree_sitter_utilities_test.rs index 9c840ef93..8f590ab3a 100644 --- a/src/utilities/unit_tests/tree_sitter_utilities_test.rs +++ b/src/utilities/unit_tests/tree_sitter_utilities_test.rs @@ -135,7 +135,7 @@ fn test_instantiate() { ]); assert_eq!( TSQuery("@variable_name foo bar @init".to_string()) - .instantiate(&substitutions) + .instantiate(&substitutions, &HashMap::new()) .0, "isFlagTreated foo bar true" ) diff --git a/test-resources/java/delete_method_invocation_argument/configurations/rules.toml b/test-resources/java/delete_method_invocation_argument/configurations/rules.toml index a6df1f923..0994f93c4 100644 --- a/test-resources/java/delete_method_invocation_argument/configurations/rules.toml +++ b/test-resources/java/delete_method_invocation_argument/configurations/rules.toml @@ -5,7 +5,7 @@ query = """( (#eq? @name "add") )""" replace_node = "args" -replace_idx = 1 +replace_idx = "one" replace = "" [[rules.filters]] sibling_count = 3