OLD | NEW |
---|---|
1 # Providing Navigation | 1 # Providing Navigation |
2 | 2 |
3 Navigation information is used by clients to allow users to navigate to the | 3 Navigation information is used by clients to allow users to navigate to the |
4 location at which an identifier is defined. | 4 location at which an identifier is defined. |
5 | 5 |
6 ## Implementation details | 6 ## Implementation details |
7 | 7 |
8 Navigation information can be requested both by an `analysis.getNavigation` | 8 Navigation information can be requested both by an `analysis.getNavigation` |
9 request and by a subscription. If the server has subscribed for navigation | 9 request and by a subscription. If the server has subscribed for navigation |
10 information in some set of files, the the plugin should send the information in | 10 information in some set of files, the the plugin should send the information in |
11 an `analysis.navigation` notification whenever the information needs to be | 11 an `analysis.navigation` notification whenever the information needs to be |
12 updated. | 12 updated. |
13 | 13 |
14 When an `analysis.getNavigation` request is received, the method | 14 When an `analysis.getNavigation` request is received, the method |
15 `handleAnalysisGetNavigation` will be invoked. This method is responsible for | 15 `handleAnalysisGetNavigation` will be invoked. This method is responsible for |
16 returning a response that contains the available navigation information. | 16 returning a response that contains the available navigation information. |
17 | 17 |
18 The easiest way to implement the method `handleAnalysisGetNavigation` is by | 18 When a notification needs to be sent, the method`sendNavigationNotification` |
scheglov
2017/08/24 18:19:21
Add a space between "method" and "`"?
| |
19 will be invoked. This method is responsible for sending the notification. | |
20 | |
21 The easiest way to add support for both the request and the notification is by | |
19 adding the classes `NavigationMixin` and `DartNavigationMixin` (from | 22 adding the classes `NavigationMixin` and `DartNavigationMixin` (from |
20 `package:analyzer_plugin/plugin/navigation_mixin.dart`) to the list of mixins | 23 `package:analyzer_plugin/plugin/navigation_mixin.dart`) to the list of mixins |
21 for your subclass of `ServerPlugin`. This will leave you with one abstract | 24 for your subclass of `ServerPlugin`. This will leave you with one abstract |
22 method that you need to implement: `getNavigationContributors`. That method is | 25 method that you need to implement: `getNavigationContributors`. That method is |
23 responsible for returning a list of `NavigationContributor`s. It is the | 26 responsible for returning a list of `NavigationContributor`s. It is the |
24 navigation contributors that produce the actual navigation information. (Most | 27 navigation contributors that produce the actual navigation information. (Most |
25 plugins will only need a single navigation contributor.) | 28 plugins will only need a single navigation contributor.) |
26 | 29 |
27 To write a navigation contributor, create a class that implements | 30 To write a navigation contributor, create a class that implements |
28 `NavigationContributor`. The interface defines a single method named | 31 `NavigationContributor`. The interface defines a single method named |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 ```dart | 76 ```dart |
74 class MyPlugin extends ServerPlugin with NavigationMixin, DartNavigationMixin { | 77 class MyPlugin extends ServerPlugin with NavigationMixin, DartNavigationMixin { |
75 // ... | 78 // ... |
76 | 79 |
77 @override | 80 @override |
78 List<NavigationContributor> getNavigationContributors(String path) { | 81 List<NavigationContributor> getNavigationContributors(String path) { |
79 return <NavigationContributor>[new MyNavigationContributor()]; | 82 return <NavigationContributor>[new MyNavigationContributor()]; |
80 } | 83 } |
81 } | 84 } |
82 ``` | 85 ``` |
OLD | NEW |