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

Unified Diff: pkg/analyzer_plugin/lib/utilities/subscription_manager.dart

Issue 2667823003: Add top-level driver and abstract plugin superclass (Closed)
Patch Set: Created 3 years, 11 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
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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698