Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: pkg/analyzer_plugin/doc/tutorial/completion.md

Issue 2998083002: Minor enhancement to the plugin tutorials (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer_plugin/doc/tutorial/assists.md ('k') | pkg/analyzer_plugin/doc/tutorial/fixes.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Providing Code Completions 1 # Providing Code Completions
2 2
3 A code completion is used by clients to provide a set of possible completions to 3 A code completion is used by clients to provide a set of possible completions to
4 partially entered code. Completions are intended to address two use cases: to 4 partially entered code. Completions are intended to address two use cases: to
5 help users enter code with less effort and to help users discover the behavior 5 help users enter code with less effort and to help users discover the behavior
6 of an object. 6 of an object.
7 7
8 For example, if the user has typed `o.toSt` and then requested completions, one 8 For example, if the user has typed `o.toSt` and then requested completions, one
9 suggestion might be `toString`. 9 suggestion might be `toString`.
10 10
(...skipping 27 matching lines...) Expand all
38 responsible for returning a list of `CompletionContributor`s. It is the 38 responsible for returning a list of `CompletionContributor`s. It is the
39 completion contributors that produce the actual completion suggestions. (Most 39 completion contributors that produce the actual completion suggestions. (Most
40 plugins will only need a single completion contributor.) 40 plugins will only need a single completion contributor.)
41 41
42 To write a completion contributor, create a class that implements 42 To write a completion contributor, create a class that implements
43 `CompletionContributor`. The interface defines a single method named 43 `CompletionContributor`. The interface defines a single method named
44 `computeSuggestions`. The method has two arguments: a `CompletionRequest` that 44 `computeSuggestions`. The method has two arguments: a `CompletionRequest` that
45 describes the where completions are being requested and a `CompletionCollector` 45 describes the where completions are being requested and a `CompletionCollector`
46 through which suggestions are to be added. 46 through which suggestions are to be added.
47 47
48 If you mix in the class `DartCompletionMixin`, then the request will be an
49 instance of `DartCompletionRequest`, which also has analysis results.
50
48 ## Example 51 ## Example
49 52
50 Start by creating a class that implements `CompletionContributor`, then 53 Start by creating a class that implements `CompletionContributor`, then
51 implement the method `computeSuggestions`. Your contributor should invoke the 54 implement the method `computeSuggestions`. Your contributor should invoke the
52 method `checkAborted`, defined on the `CompletionRequest` object, before 55 method `checkAborted`, defined on the `CompletionRequest` object, before
53 starting any slow work. This allows the computation of completion suggestions 56 starting any slow work. This allows the computation of completion suggestions
54 to be preempted if the client no longer needs the results. 57 to be preempted if the client no longer needs the results.
55 58
56 For example, your contributor might look something like the following: 59 For example, your contributor might look something like the following:
57 60
(...skipping 14 matching lines...) Expand all
72 class MyPlugin extends ServerPlugin with CompletionMixin, DartCompletionMixin { 75 class MyPlugin extends ServerPlugin with CompletionMixin, DartCompletionMixin {
73 // ... 76 // ...
74 77
75 @override 78 @override
76 List<CompletionContributor> getCompletionContributors( 79 List<CompletionContributor> getCompletionContributors(
77 AnalysisDriverGeneric driver) { 80 AnalysisDriverGeneric driver) {
78 return <CompletionContributor>[new MyCompletionContributor()]; 81 return <CompletionContributor>[new MyCompletionContributor()];
79 } 82 }
80 } 83 }
81 ``` 84 ```
OLDNEW
« no previous file with comments | « pkg/analyzer_plugin/doc/tutorial/assists.md ('k') | pkg/analyzer_plugin/doc/tutorial/fixes.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698