Index: pkg/analyzer_plugin/lib/plugin/plugin.dart |
diff --git a/pkg/analyzer_plugin/lib/plugin/plugin.dart b/pkg/analyzer_plugin/lib/plugin/plugin.dart |
index 5179732ddcb50f0f62652a43686f39e0ab5561c6..496eb49809a54d9cbd334ff244082180a251ddae 100644 |
--- a/pkg/analyzer_plugin/lib/plugin/plugin.dart |
+++ b/pkg/analyzer_plugin/lib/plugin/plugin.dart |
@@ -4,6 +4,7 @@ |
import 'dart:async'; |
+import 'package:analyzer/dart/analysis/results.dart'; |
import 'package:analyzer/file_system/file_system.dart'; |
import 'package:analyzer/file_system/physical_file_system.dart'; |
import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
@@ -427,13 +428,95 @@ abstract class ServerPlugin { |
void onError(Object exception, StackTrace stackTrace) {} |
/** |
- * Send notifications corresponding to the given description of subscriptions. |
- * The map is keyed by the path of each file for which notifications should be |
- * sent and has values representing the list of services associated with the |
- * notifications to send. |
+ * If the plugin provides folding information, send a folding notification |
+ * for the file with the given [path] to the server. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ Future<Null> sendFoldingNotification(String path, {ResolveResult result}) { |
+ return new Future.value(); |
+ } |
+ |
+ /** |
+ * If the plugin provides highlighting information, send a highlights |
+ * notification for the file with the given [path] to the server. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ Future<Null> sendHighlightsNotification(String path, {ResolveResult result}) { |
scheglov
2017/08/22 17:55:27
I think `result` must be a required parameter in a
Brian Wilkerson
2017/08/22 18:33:15
For performance reasons? In spite of the fact that
scheglov
2017/08/22 18:49:21
Well, you're probably right.
It's OK with me to ke
Brian Wilkerson
2017/08/23 14:06:43
But we need to keep them?
If I've understood Mike
|
+ return new Future.value(); |
+ } |
+ |
+ /** |
+ * If the plugin provides navigation information, send a navigation |
+ * notification for the file with the given [path] to the server. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ Future<Null> sendNavigationNotification(String path, {ResolveResult result}) { |
+ return new Future.value(); |
+ } |
+ |
+ /** |
+ * Send notifications for the services subscribed to for the file with the |
+ * given [path]. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ * |
+ * This is a convenience method that subclasses can use to send notifications |
+ * after analysis has been performed on a file. |
+ */ |
+ void sendNotificationsForFile(String path, {ResolveResult result}) { |
+ for (AnalysisService service in subscriptionManager.servicesForFile(path)) { |
+ _sendNotificationForFile(path, service, result: result); |
+ } |
+ } |
+ |
+ /** |
+ * Send notifications corresponding to the given description of |
+ * [subscriptions]. The map is keyed by the path of each file for which |
+ * notifications should be sent and has values representing the list of |
+ * services associated with the notifications to send. |
+ * |
+ * This method is used when the set of subscribed notifications has been |
+ * changed and notifications need to be sent even when the specified files |
+ * have already been analyzed. |
*/ |
void sendNotificationsForSubscriptions( |
- Map<String, List<AnalysisService>> subscriptions); |
+ Map<String, List<AnalysisService>> subscriptions) { |
+ subscriptions.forEach((String path, List<AnalysisService> services) { |
+ for (AnalysisService service in services) { |
+ _sendNotificationForFile(path, service); |
+ } |
+ }); |
+ } |
+ |
+ /** |
+ * If the plugin provides occurrences information, send an occurrences |
+ * notification for the file with the given [path] to the server. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ Future<Null> sendOccurrencesNotification(String path, |
+ {ResolveResult result}) { |
+ return new Future.value(); |
+ } |
+ |
+ /** |
+ * If the plugin provides outline information, send an outline notification |
+ * for the file with the given [path] to the server. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ Future<Null> sendOutlineNotification(String path, {ResolveResult result}) { |
+ return new Future.value(); |
+ } |
/** |
* Start this plugin by listening to the given communication [channel]. |
@@ -562,4 +645,32 @@ abstract class ServerPlugin { |
_channel.sendResponse(response); |
} |
} |
+ |
+ /** |
+ * Send a notification for the file at the given [path] corresponding to the |
+ * given [service]. |
+ * |
+ * If a [result] is provided then it is expected to be the result of analyzing |
+ * the file at the given [path]. |
+ */ |
+ void _sendNotificationForFile(String path, AnalysisService service, |
+ {ResolveResult result}) { |
+ switch (service) { |
+ case AnalysisService.FOLDING: |
+ sendFoldingNotification(path, result: result); |
+ break; |
+ case AnalysisService.HIGHLIGHTS: |
+ sendHighlightsNotification(path, result: result); |
+ break; |
+ case AnalysisService.NAVIGATION: |
+ sendNavigationNotification(path, result: result); |
+ break; |
+ case AnalysisService.OCCURRENCES: |
+ sendOccurrencesNotification(path, result: result); |
+ break; |
+ case AnalysisService.OUTLINE: |
+ sendOutlineNotification(path, result: result); |
+ break; |
+ } |
+ } |
} |