OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:core'; | 9 import 'dart:core'; |
10 | 10 |
11 import 'package:analyzer/file_system/file_system.dart'; | 11 import 'package:analyzer/file_system/file_system.dart'; |
12 import 'package:watcher/watcher.dart'; | 12 import 'package:watcher/watcher.dart'; |
13 | 13 |
14 /** | 14 /** |
15 * A function called when a watch [event] associated with a watched resource is | 15 * A function called when a watch [event] associated with a watched resource is |
16 * received. The list of [tokens] will contain all of the tokens associated with | 16 * received. The list of [tokens] will contain all of the tokens associated with |
17 * folders containing (or the same as) the watched resource. | 17 * folders containing (or the same as) the watched resource. |
18 */ | 18 */ |
19 typedef void HandleWatchEvent<T>(WatchEvent event, List<T> tokens); | 19 typedef void HandleWatchEvent<T>(WatchEvent event, List<T> tokens); |
20 | 20 |
21 /** | 21 /** |
22 * An object that manages a collections of folders that need to be watched in | 22 * An object that manages a collections of folders that need to be watched in |
23 * order to ensure that we are watching the minimum number of folders. | 23 * order to ensure that we are watching the minimum number of folders. |
24 * | 24 * |
25 * Each folder can be watched multiple times. In order to differenciate between | 25 * Each folder can be watched multiple times. In order to differentiate between |
26 * the watch requests, each watch request has a *token* associated with it. The | 26 * the watch requests, each watch request has a *token* associated with it. The |
27 * tokens that are used must correctly implement both [==] and [hashCode]. | 27 * tokens that are used must correctly implement both [==] and [hashCode]. |
28 */ | 28 */ |
29 class WatchManager<T> { | 29 class WatchManager<T> { |
30 /** | 30 /** |
31 * The resource provider used to convert paths to resources. | 31 * The resource provider used to convert paths to resources. |
32 */ | 32 */ |
33 final ResourceProvider provider; | 33 final ResourceProvider provider; |
34 | 34 |
35 /** | 35 /** |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 void _removeChild(WatchNode<T> child) { | 278 void _removeChild(WatchNode<T> child) { |
279 _children.remove(child); | 279 _children.remove(child); |
280 Iterable<WatchNode<T>> grandchildren = child.children; | 280 Iterable<WatchNode<T>> grandchildren = child.children; |
281 for (WatchNode<T> grandchild in grandchildren) { | 281 for (WatchNode<T> grandchild in grandchildren) { |
282 grandchild.parent = this; | 282 grandchild.parent = this; |
283 _children.add(grandchild); | 283 _children.add(grandchild); |
284 } | 284 } |
285 child._children.clear(); | 285 child._children.clear(); |
286 } | 286 } |
287 } | 287 } |
OLD | NEW |