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