OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Support for client code that extends the analysis aspect of analysis server. | 6 * Support for client code that interacts with the analysis domain of an |
| 7 * analysis server. |
| 8 * |
| 9 * Plugins can gain access to the request handler that implements the analysis |
| 10 * domain in order to extend the functionality of that domain. The class |
| 11 * [AnalysisDomain] defines the API of the analysis domain that plugins can use. |
| 12 * |
| 13 * If a plugin is interested in gaining access to the analysis domain, it should |
| 14 * register a function by including code like the following in the plugin's |
| 15 * registerExtensions method: |
| 16 * |
| 17 * AnalysisDomain analysisDomain; |
| 18 * |
| 19 * @override |
| 20 * void registerExtensions(RegisterExtension registerExtension) { |
| 21 * ... |
| 22 * registerExtension( |
| 23 * SET_ANALYSIS_DOMAIN_EXTENSION_POINT_ID, |
| 24 * (AnalysisDomain domain) => analysisDomain = domain); |
| 25 * ... |
| 26 * } |
7 */ | 27 */ |
8 library analysis_server.analysis; | 28 library analysis_server.analysis; |
9 | 29 |
10 import 'dart:async'; | 30 import 'dart:async'; |
11 | 31 |
12 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 32 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
13 import 'package:analysis_server/src/protocol.dart' show AnalysisService; | 33 import 'package:analysis_server/src/protocol.dart' show AnalysisService; |
14 import 'package:analyzer/src/generated/engine.dart' | 34 import 'package:analyzer/src/generated/engine.dart' |
15 show AnalysisContext, ComputedResult; | 35 show AnalysisContext, ComputedResult; |
16 import 'package:analyzer/src/generated/source.dart' show Source; | 36 import 'package:analyzer/src/generated/source.dart' show Source; |
17 import 'package:analyzer/task/model.dart' show ResultDescriptor; | 37 import 'package:analyzer/task/model.dart' show ResultDescriptor; |
18 import 'package:plugin/plugin.dart'; | 38 import 'package:plugin/plugin.dart'; |
19 | 39 |
20 /** | 40 /** |
21 * The identifier of the extension point that allows plugins to get access to | 41 * The identifier of the extension point that allows plugins to get access to an |
22 * `AnalysisSite`. The object used as an extension must be | 42 * [AnalysisDomain]. The object used as an extension must be a |
23 * a [SetAnalysisDomain]. | 43 * [SetAnalysisDomain]. |
24 */ | 44 */ |
25 final String SET_ANALYSIS_DOMAIN_EXTENSION_POINT_ID = Plugin.join( | 45 final String SET_ANALYSIS_DOMAIN_EXTENSION_POINT_ID = Plugin.join( |
26 ServerPlugin.UNIQUE_IDENTIFIER, | 46 ServerPlugin.UNIQUE_IDENTIFIER, |
27 ServerPlugin.SET_ANALISYS_DOMAIN_EXTENSION_POINT); | 47 ServerPlugin.SET_ANALISYS_DOMAIN_EXTENSION_POINT); |
28 | 48 |
29 /** | 49 /** |
30 * A function that is invoked on the `analysis` domain creation. | 50 * A function that is invoked after the analysis domain has been created and is |
| 51 * initialized. |
31 */ | 52 */ |
32 typedef void SetAnalysisDomain(AnalysisDomain site); | 53 typedef void SetAnalysisDomain(AnalysisDomain domain); |
33 | 54 |
34 /** | 55 /** |
35 * An object that gives [SetAnalysisDomain]s access to the `analysis` domain | 56 * An object that gives plugins access to the analysis domain of the analysis |
36 * of the analysis server. | 57 * server. |
37 * | 58 * |
38 * Clients are not expected to subtype this class. | 59 * Clients are not expected to subtype this class. |
39 */ | 60 */ |
40 abstract class AnalysisDomain { | 61 abstract class AnalysisDomain { |
41 /** | 62 /** |
42 * Return the stream that is notified when a new value for the given | 63 * Return the stream that is notified when a new value for the given |
43 * [descriptor] is computed. | 64 * [result] is computed. |
| 65 * |
| 66 * This method should be used by plugins that need to perform some additional |
| 67 * processing after analysis has completed. One example would be a plugin that |
| 68 * needed to send a notification to the client because some data was now |
| 69 * invalidated. |
44 */ | 70 */ |
45 Stream<ComputedResult> onResultComputed(ResultDescriptor descriptor); | 71 Stream<ComputedResult> onResultComputed(ResultDescriptor result); |
46 | 72 |
47 /** | 73 /** |
48 * Schedule sending the given [service] notifications for the given [source] | 74 * Schedule sending the given [service] notifications for the given [source] |
49 * in the given [context]. | 75 * in the given [context]. |
50 */ | 76 */ |
51 void scheduleNotification( | 77 void scheduleNotification( |
52 AnalysisContext context, Source source, AnalysisService service); | 78 AnalysisContext context, Source source, AnalysisService service); |
53 } | 79 } |
OLD | NEW |