OLD | NEW |
1 # Providing Outlines | 1 # Providing Outlines |
2 | 2 |
3 Outline information is used by clients to allow users to see the structure of | 3 Outline information is used by clients to allow users to see the structure of |
4 their code. | 4 their code. |
5 | 5 |
6 ## Implementation details | 6 ## Implementation details |
7 | 7 |
8 Outline information is available through a subscription. If the server has | 8 Outline information is available through a subscription. If the server has |
9 subscribed for outline information in some set of files, then the plugin should | 9 subscribed for outline information in some set of files, then the plugin should |
10 send the information in an `analysis.outline` notification whenever the | 10 send the information in an `analysis.outline` notification whenever the |
11 information needs to be updated. | 11 information needs to be updated. |
12 | 12 |
13 When a notification needs to be sent, the method`sendOutlineNotification` will | 13 When a notification needs to be sent, the method `sendOutlineNotification` will |
14 be invoked. This method is responsible for sending the notification. | 14 be invoked. This method is responsible for sending the notification. |
15 | 15 |
16 The easiest way to add support for this notification is by adding the classes | 16 The easiest way to add support for this notification is by adding the classes |
17 `OutlineMixin` and `DartOutlineMixin` (from | 17 `OutlineMixin` and `DartOutlineMixin` (from |
18 `package:analyzer_plugin/plugin/outline_mixin.dart`) to the list of mixins | 18 `package:analyzer_plugin/plugin/outline_mixin.dart`) to the list of mixins |
19 for your subclass of `ServerPlugin`. This will leave you with one abstract | 19 for your subclass of `ServerPlugin`. This will leave you with one abstract |
20 method that you need to implement: `getOutlineContributors`. That method is | 20 method that you need to implement: `getOutlineContributors`. That method is |
21 responsible for returning a list of `OutlineContributor`s. It is the outline | 21 responsible for returning a list of `OutlineContributor`s. It is the outline |
22 contributors that produce the actual outline information. (Most plugins will | 22 contributors that produce the actual outline information. (Most plugins will |
23 only need a single outline contributor.) | 23 only need a single outline contributor.) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ```dart | 71 ```dart |
72 class MyPlugin extends ServerPlugin with OutlineMixin, DartOutlineMixin { | 72 class MyPlugin extends ServerPlugin with OutlineMixin, DartOutlineMixin { |
73 // ... | 73 // ... |
74 | 74 |
75 @override | 75 @override |
76 List<OutlineContributor> getOutlineContributors(String path) { | 76 List<OutlineContributor> getOutlineContributors(String path) { |
77 return <OutlineContributor>[new MyOutlineContributor()]; | 77 return <OutlineContributor>[new MyOutlineContributor()]; |
78 } | 78 } |
79 } | 79 } |
80 ``` | 80 ``` |
OLD | NEW |