uber / piranha

A tool for refactoring code related to feature flag APIs
Apache License 2.0
2.29k stars 198 forks source link

Add a new edge kind - `ParentIterative` #617

Closed ketkarameya closed 1 year ago

ketkarameya commented 1 year ago

Earlier we had Parent and this is how it was processed:

for rule in graph.outgoing(current_rule, PARENT):
   for ancestor in context(current_location):
       Edit edit = get_edit(rule, ancestor)
       if edit : 
          return edit 

For ParentIterative we do something subtly different. We loop over the ancestors in the outer most loop: And its processed something like :

   for ancestor in context(current_location):
       for rule in graph.outgoing(current_rule, PARENT_ITERATIVE):
         Edit edit = get_edit(rule, ancestor)
         if edit : 
          return edit 

Why suffix iterative? I thought its keeping to iterative-deepening idea from DFS. I am open to other names. But this pattern makes it easy to transform builder patterns (As required by Scala upgrade folks)