Open eankit opened 1 year ago
https://github.com/uber/piranha/pull/630
I added a demo with your example.
Give it a try
@ketkarameya thanks this works.
can you also help me with this use case as well // Some code if (experiment.isTreated(someObject, "STALE_FLAG")) { // Do something } else { // Do something else } // Do other things }
@eankit i will have to know more about your API to help you. Can you please DM me ?
Hey @ketkarameya My issue is this if (experiment.isTreated(arg1, arg2, "STALE_FLAG")) { // Do something } else { // Do something else } I want to run Piranha on this api. Here we have a simple feature flag string with a few arguments in the function. I tried hardcoding the argument and it worked, but I want to understand how to work with a variable argument list. Also, I saw in rules.toml file that you work on argument list for a simple example, something of a similar solution is expected for the String flag name. _arguments: ((argument_list ([ (fieldaccess field: ()@argument) () @argument ])) )
Also, I want to understand how can I write my own query like the following, do you have any documentation for this? query='cs :[e].isFeatureEnabled("@flag_name")', For example, I want to skip the experiment. in experiment.isTreated("STALE_FLAG") and work with only isTreated("STALE_FLAG") how can that be done
Unfortunately there is no documentation for concrete syntax.
(
(method_invocation (argument_list (string_literal (_) @flag_name) @string_literal)) @mi
(#eq? @flag_name "@flag_name")
)
equivalent concrete syntax is
:[r].isTreated(:[a0], :[a1], ":[flag_name]")
Can a string with double quotes be cleaned by polygot poranha, code snipped below, If yes, how ?
void demoMethod(ExperimentAPI experiment){ // Some code if (experiment.isTreated("STALE_FLAG")) { // Do something } else { // Do something else } // Do other things }