Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coala/cEPs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 42015fcc7887c003791fe238c99be95d305fd18f
Choose a base ref
..
head repository: coala/cEPs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 974d552c357e69584912c45f7f280d493b7fb6ee
Choose a head ref
Showing with 12 additions and 12 deletions.
  1. +12 −12 cEP-0030.md
24 changes: 12 additions & 12 deletions cEP-0030.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ will allow bears to define their own actions as a part of

# Introduction

Bears run some analysis on a piece of code and output is in form of
Bears run some analysis on a piece of code and output is in the form of
a `Result` object. Then some action from a predefined set of actions
is applied to that `Result` object. This system is a bit restrictive
as only an action from predefined set of actions can be taken.
@@ -26,22 +26,22 @@ own actions, then it will make bears more useful.
This project is about modifying the current action system so that bears
can define their own actions.
This project also aims to implement a new action which will help in
supporting for bears to provide mulitple patches for the affected code.
supporting for bears to provide multiple patches for the affected code.


# Support for bears to define their own actions

The idea is to add a new attribute to `Result` class which will be a list of
action instances defined by origin of the Result. When bears yield a Result,
action instances defined by origin of the Result. When bears yield a Result,
they can pass optional argument defining actions.
Then actions in `result.actions` are added to list of predefined actions when
the user is asked for an action to apply.
Then actions in `result.actions` are added to the list of predefined actions
when the user is asked for an action to apply.

## Changing the `Result` class

1. The first step is to facilitate bears defining their own actions. For this
the `__init__` and `from_values` method of the Result class are be changed.
While yielding Result object a new optional parameter `actions` can be passed.
1. The first step is to facilitate bears defining their own actions. For this
the `__init__` and `from_values` method of the Result class are to be changed.
While yielding Result object a new optional parameter `actions` can be passed.
This is a list of actions that are specific to the bear.

```python
@@ -162,7 +162,7 @@ def autoapply_actions(results,
for result in results:
bear_actions += result.actions

# `bear_actions` is passed as a argument to `get_default_actions` function.
# `bear_actions` is passed as an argument to `get_default_actions` function.
default_actions, invalid_actions = get_default_actions(section,
bear_actions)
no_autoapply_warn = bool(section.get('no_autoapply_warn', False))
@@ -385,7 +385,7 @@ class AddNewlineAction(ResultAction):
Currently bears suggest the patches in form of `diffs`, to facilitate bears
suggesting multiple patches we add a new attribute to `Result` class,
`alternate_diffs`. It is a list of alternate patches suggested by the bear.
For each alternate patch we have add an `AlternatePatchAction` to list of
For each alternate patch we add an `AlternatePatchAction` to list of
actions.

## Changing the `Result` class
@@ -458,7 +458,7 @@ it in a `diffs` attribute.
2. The basic idea is to swaps the values of `result.diffs` and `self.diffs`
and then apply `ShowPatchAction`. This will show the alternate patch to the
user. After this user chooses `ApplyPatchAction` then changes made are
correspoding to the alternate patch.
corresponding to the alternate patch.

```python

@@ -492,7 +492,7 @@ class AlternatePatchAction(ResultAction):
## Modifying `ConsoleInteraction` module

1. A new function `get_alternate_patch_action` is defined. It takes a result
object as parameter and returns a tuple of `AlternatePatchAction` instances,
object as a parameter and returns a tuple of `AlternatePatchAction` instances,
each corresponding to an alternative patch.

```python