OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'package:analyzer_plugin/protocol/generated_protocol.dart'; |
| 6 |
| 7 /** |
| 8 * An object that manages the subscriptions for analysis results. |
| 9 */ |
| 10 class SubscriptionManager { |
| 11 /** |
| 12 * The current set of subscriptions. |
| 13 */ |
| 14 Map<AnalysisService, List<String>> _subscriptions; |
| 15 |
| 16 /** |
| 17 * Initialize a newly created subscription manager to have no subscriptions. |
| 18 */ |
| 19 SubscriptionManager(); |
| 20 |
| 21 /** |
| 22 * Return a list of the services for which the file with the given [filePath] |
| 23 * has been subscribed. |
| 24 */ |
| 25 List<AnalysisService> servicesForFile(String filePath) { |
| 26 List<AnalysisService> services = <AnalysisService>[]; |
| 27 if (_subscriptions != null) { |
| 28 _subscriptions.forEach((AnalysisService service, List<String> files) { |
| 29 if (files.contains(filePath)) { |
| 30 services.add(service); |
| 31 } |
| 32 }); |
| 33 } |
| 34 return services; |
| 35 } |
| 36 |
| 37 /** |
| 38 * Set the current set of subscriptions to those described by the given map of |
| 39 * [subscriptions]. |
| 40 */ |
| 41 void setSubscriptions(Map<AnalysisService, List<String>> subscriptions) { |
| 42 _subscriptions = subscriptions; |
| 43 } |
| 44 } |
OLD | NEW |