Index: pkg/analyzer_plugin/lib/utilities/subscription_manager.dart |
diff --git a/pkg/analyzer_plugin/lib/utilities/subscription_manager.dart b/pkg/analyzer_plugin/lib/utilities/subscription_manager.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b73d853f384335eaa0abecf74fe9d8fa77cf271 |
--- /dev/null |
+++ b/pkg/analyzer_plugin/lib/utilities/subscription_manager.dart |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'package:analyzer_plugin/protocol/generated_protocol.dart'; |
+ |
+/** |
+ * An object that manages the subscriptions for analysis results. |
+ */ |
+class SubscriptionManager { |
+ /** |
+ * The current set of subscriptions. |
+ */ |
+ Map<AnalysisService, List<String>> _subscriptions; |
+ |
+ /** |
+ * Initialize a newly created subscription manager to have no subscriptions. |
+ */ |
+ SubscriptionManager(); |
+ |
+ /** |
+ * Return a list of the services for which the file with the given [filePath] |
+ * has been subscribed. |
+ */ |
+ List<AnalysisService> servicesForFile(String filePath) { |
+ List<AnalysisService> services = <AnalysisService>[]; |
+ if (_subscriptions != null) { |
+ _subscriptions.forEach((AnalysisService service, List<String> files) { |
+ if (files.contains(filePath)) { |
+ services.add(service); |
+ } |
+ }); |
+ } |
+ return services; |
+ } |
+ |
+ /** |
+ * Set the current set of subscriptions to those described by the given map of |
+ * [subscriptions]. |
+ */ |
+ void setSubscriptions(Map<AnalysisService, List<String>> subscriptions) { |
+ _subscriptions = subscriptions; |
+ } |
+} |