Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: pkg/analyzer_plugin/lib/plugin/plugin.dart

Issue 3003573002: Add minimal support for sending notifications (Closed)
Patch Set: Removed optional parameter Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer_plugin/test/plugin/mocks.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d90d68a2199c5ff12f892e087ad5afe3000888f 100644
--- a/pkg/analyzer_plugin/lib/plugin/plugin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/plugin.dart
@@ -427,13 +427,76 @@ 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.
+ */
+ Future<Null> sendFoldingNotification(String path) {
+ return new Future.value();
+ }
+
+ /**
+ * If the plugin provides highlighting information, send a highlights
+ * notification for the file with the given [path] to the server.
+ */
+ Future<Null> sendHighlightsNotification(String path) {
+ return new Future.value();
+ }
+
+ /**
+ * If the plugin provides navigation information, send a navigation
+ * notification for the file with the given [path] to the server.
+ */
+ Future<Null> sendNavigationNotification(String path) {
+ return new Future.value();
+ }
+
+ /**
+ * Send notifications for the services subscribed to for the file with 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) {
+ for (AnalysisService service in subscriptionManager.servicesForFile(path)) {
+ _sendNotificationForFile(path, service);
+ }
+ }
+
+ /**
+ * 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.
+ */
+ Future<Null> sendOccurrencesNotification(String path) {
+ return new Future.value();
+ }
+
+ /**
+ * If the plugin provides outline information, send an outline notification
+ * for the file with the given [path] to the server.
+ */
+ Future<Null> sendOutlineNotification(String path) {
+ return new Future.value();
+ }
/**
* Start this plugin by listening to the given communication [channel].
@@ -562,4 +625,28 @@ abstract class ServerPlugin {
_channel.sendResponse(response);
}
}
+
+ /**
+ * Send a notification for the file at the given [path] corresponding to the
+ * given [service].
+ */
+ void _sendNotificationForFile(String path, AnalysisService service) {
+ switch (service) {
+ case AnalysisService.FOLDING:
+ sendFoldingNotification(path);
+ break;
+ case AnalysisService.HIGHLIGHTS:
+ sendHighlightsNotification(path);
+ break;
+ case AnalysisService.NAVIGATION:
+ sendNavigationNotification(path);
+ break;
+ case AnalysisService.OCCURRENCES:
+ sendOccurrencesNotification(path);
+ break;
+ case AnalysisService.OUTLINE:
+ sendOutlineNotification(path);
+ break;
+ }
+ }
}
« no previous file with comments | « no previous file | pkg/analyzer_plugin/test/plugin/mocks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698