| OLD | NEW |
| 1 # Providing Quick Assists | 1 # Providing Quick Assists |
| 2 | 2 |
| 3 A quick assist is used by clients to provide a set of possible changes to code | 3 A quick assist is used by clients to provide a set of possible changes to code |
| 4 that are based on the structure of the code. Quick assists are intended to help | 4 that are based on the structure of the code. Quick assists are intended to help |
| 5 users safely make local changes to code when those changes do not require any | 5 users safely make local changes to code when those changes do not require any |
| 6 user interaction. (Modifications that require interaction with users or that | 6 user interaction. (Modifications that require interaction with users or that |
| 7 touch multiple files are usually implemented as refactorings.) | 7 touch multiple files are usually implemented as refactorings.) |
| 8 | 8 |
| 9 For example, if the user has a function whose body consists of a single return | 9 For example, if the user has a function whose body consists of a single return |
| 10 statement in a block, server will provide an assist to convert the function body | 10 statement in a block, server will provide an assist to convert the function body |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 That method is responsible for returning a list of `AssistContributor`s. It is | 31 That method is responsible for returning a list of `AssistContributor`s. It is |
| 32 the assist contributors that produce the actual assists. (Most plugins will only | 32 the assist contributors that produce the actual assists. (Most plugins will only |
| 33 need a single assist contributor.) | 33 need a single assist contributor.) |
| 34 | 34 |
| 35 To write an assist contributor, create a class that implements | 35 To write an assist contributor, create a class that implements |
| 36 `AssistContributor`. The interface defines a single method named | 36 `AssistContributor`. The interface defines a single method named |
| 37 `computeAssists`. The method has two arguments: an `AssistRequest` that | 37 `computeAssists`. The method has two arguments: an `AssistRequest` that |
| 38 describes the location at which assists were requested and an `AssistCollector` | 38 describes the location at which assists were requested and an `AssistCollector` |
| 39 through which assists are to be added. | 39 through which assists are to be added. |
| 40 | 40 |
| 41 If you mix in the class `DartAssistsMixin`, then the request will be an instance |
| 42 of `DartAssistRequest`, which also has analysis results. |
| 43 |
| 41 The class `AssistContributorMixin` defines a support method that makes it easier | 44 The class `AssistContributorMixin` defines a support method that makes it easier |
| 42 to implement `computeAssists`. | 45 to implement `computeAssists`. |
| 43 | 46 |
| 44 ## Example | 47 ## Example |
| 45 | 48 |
| 46 Start by creating a class that implements `AssistContributor` and that mixes in | 49 Start by creating a class that implements `AssistContributor` and that mixes in |
| 47 the class `AssistContributorMixin`, then implement the method `computeAssists`. | 50 the class `AssistContributorMixin`, then implement the method `computeAssists`. |
| 48 This method is typically implemented as a sequence of invocations of methods | 51 This method is typically implemented as a sequence of invocations of methods |
| 49 that check to see whether a given assist is appropriate in the context of the | 52 that check to see whether a given assist is appropriate in the context of the |
| 50 request | 53 request |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // ... | 99 // ... |
| 97 | 100 |
| 98 @override | 101 @override |
| 99 List<AssistContributor> getAssistContributors(AnalysisDriver driver) { | 102 List<AssistContributor> getAssistContributors(AnalysisDriver driver) { |
| 100 return <AssistContributor>[new MyAssistContributor()]; | 103 return <AssistContributor>[new MyAssistContributor()]; |
| 101 } | 104 } |
| 102 } | 105 } |
| 103 ``` | 106 ``` |
| 104 | 107 |
| 105 [creatingEdits]: creating_edits.md | 108 [creatingEdits]: creating_edits.md |
| OLD | NEW |