Evaluations for Phase start on 22nd July and I have pretty much completed all my milestones for Phase 2. I have successfully provided support for bears to suggest mulitple patches. It took me lot of time to think about how to implement this because there were many possibilities about how some little things could have been done. Some of them didn’t work out and others were not very good. Finally I had an epiphany of sorts and came up with a pretty good solution actually.
The plan was to add a new attribute to the Result
class called alternate_diffs
. Bears can pass a list of alternate patches and they are stored in alternate_diffs
. Later in ConsoleInteraction
for each alternate_diff
in alternate_diffs
a instance of AlternatePatchAction
was added. The idea is very similiar to adding mulitple instances of ShowPatchAction
but since there is no diffs
associated with an instance of ShowPathAction
, AlternatePatchAction
acts kind of like a wrapper and helps manipulate between the original patch and alternate patches. When an AlternatePatchAction
is applied it swaps the value of result.diffs
and self.diffs
and calls ShowPatchAction
with updated result.
This all sounded good but there were couple of small hiccups, coala creates a dictionary of all the actions with key as the name of the class. So with mutiple instances of AlternatePatchAction
this was a bit of a problem as keys have to unique. When user is asked for an action to use, what gets printed on the screen as action description is whatever is the docstring of apply function of that action class. It don’t understand the choice of this but since docstring is same for all the instances, this was another problem. Finding a solution for this was not very difficult and you can check out the whole PR here.