OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; |
8 import 'package:analysis_server/src/channel/channel.dart'; | 8 import 'package:analysis_server/src/channel/channel.dart'; |
9 import 'package:analysis_server/src/plugin/result_collector.dart'; | 9 import 'package:analysis_server/src/plugin/result_collector.dart'; |
10 import 'package:analysis_server/src/plugin/result_converter.dart'; | 10 import 'package:analysis_server/src/plugin/result_converter.dart'; |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 /** | 42 /** |
43 * A list of the paths of files and directories that are excluded from | 43 * A list of the paths of files and directories that are excluded from |
44 * analysis. | 44 * analysis. |
45 */ | 45 */ |
46 List<String> excludedPaths = <String>[]; | 46 List<String> excludedPaths = <String>[]; |
47 | 47 |
48 /** | 48 /** |
49 * The current set of subscriptions to which the client has subscribed. | 49 * The current set of subscriptions to which the client has subscribed. |
50 */ | 50 */ |
51 Map<server.AnalysisService, List<String>> currentSubscriptions = | 51 Map<server.AnalysisService, Set<String>> currentSubscriptions = |
52 <server.AnalysisService, List<String>>{}; | 52 <server.AnalysisService, Set<String>>{}; |
53 | 53 |
54 /** | 54 /** |
55 * The collector being used to collect the analysis errors from the plugins. | 55 * The collector being used to collect the analysis errors from the plugins. |
56 */ | 56 */ |
57 ResultCollector<List<server.AnalysisError>> errors; | 57 ResultCollector<List<server.AnalysisError>> errors; |
58 | 58 |
59 /** | 59 /** |
60 * The collector being used to collect the folding regions from the plugins. | 60 * The collector being used to collect the folding regions from the plugins. |
61 */ | 61 */ |
62 ResultCollector<List<server.FoldingRegion>> folding; | 62 ResultCollector<List<server.FoldingRegion>> folding; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 */ | 287 */ |
288 void setAnalysisRoots(List<String> included, List<String> excluded) { | 288 void setAnalysisRoots(List<String> included, List<String> excluded) { |
289 includedPaths = included; | 289 includedPaths = included; |
290 excludedPaths = excluded; | 290 excludedPaths = excluded; |
291 } | 291 } |
292 | 292 |
293 /** | 293 /** |
294 * Set the current subscriptions to the given set of [newSubscriptions]. | 294 * Set the current subscriptions to the given set of [newSubscriptions]. |
295 */ | 295 */ |
296 void setSubscriptions( | 296 void setSubscriptions( |
297 Map<server.AnalysisService, List<String>> newSubscriptions) { | 297 Map<server.AnalysisService, Set<String>> newSubscriptions) { |
298 /** | 298 /** |
299 * Return the collector associated with the given service, or `null` if the | 299 * Return the collector associated with the given service, or `null` if the |
300 * service is not handled by this manager. | 300 * service is not handled by this manager. |
301 */ | 301 */ |
302 ResultCollector collectorFor(server.AnalysisService service) { | 302 ResultCollector collectorFor(server.AnalysisService service) { |
303 switch (service) { | 303 switch (service) { |
304 case server.AnalysisService.FOLDING: | 304 case server.AnalysisService.FOLDING: |
305 return folding; | 305 return folding; |
306 case server.AnalysisService.HIGHLIGHTS: | 306 case server.AnalysisService.HIGHLIGHTS: |
307 return highlights; | 307 return highlights; |
308 case server.AnalysisService.NAVIGATION: | 308 case server.AnalysisService.NAVIGATION: |
309 return navigation; | 309 return navigation; |
310 case server.AnalysisService.OCCURRENCES: | 310 case server.AnalysisService.OCCURRENCES: |
311 return occurrences; | 311 return occurrences; |
312 case server.AnalysisService.OUTLINE: | 312 case server.AnalysisService.OUTLINE: |
313 return outlines; | 313 return outlines; |
314 } | 314 } |
315 return null; | 315 return null; |
316 } | 316 } |
317 | 317 |
318 Set<server.AnalysisService> services = | 318 Set<server.AnalysisService> services = |
319 new HashSet<server.AnalysisService>(); | 319 new HashSet<server.AnalysisService>(); |
320 services.addAll(currentSubscriptions.keys); | 320 services.addAll(currentSubscriptions.keys); |
321 services.addAll(newSubscriptions.keys); | 321 services.addAll(newSubscriptions.keys); |
322 services.forEach((server.AnalysisService service) { | 322 services.forEach((server.AnalysisService service) { |
323 ResultCollector collector = collectorFor(service); | 323 ResultCollector collector = collectorFor(service); |
324 if (collector != null) { | 324 if (collector != null) { |
325 List<String> currentPaths = currentSubscriptions[service]; | 325 Set<String> currentPaths = currentSubscriptions[service]; |
326 List<String> newPaths = newSubscriptions[service]; | 326 Set<String> newPaths = newSubscriptions[service]; |
327 if (currentPaths == null) { | 327 if (currentPaths == null) { |
328 if (newPaths == null) { | 328 if (newPaths == null) { |
329 // This should not happen. | 329 // This should not happen. |
330 return; | 330 return; |
331 } | 331 } |
332 // All of the [newPaths] need to be added. | 332 // All of the [newPaths] need to be added. |
333 newPaths.forEach((String filePath) { | 333 newPaths.forEach((String filePath) { |
334 collector.startCollectingFor(filePath); | 334 collector.startCollectingFor(filePath); |
335 }); | 335 }); |
336 } else if (newPaths == null) { | 336 } else if (newPaths == null) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 } | 379 } |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
383 // TODO(brianwilkerson) Return false if error notifications are globally | 383 // TODO(brianwilkerson) Return false if error notifications are globally |
384 // disabled. | 384 // disabled. |
385 return isIncluded() && !isExcluded(); | 385 return isIncluded() && !isExcluded(); |
386 } | 386 } |
387 } | 387 } |
OLD | NEW |