| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 9 |
| 10 import 'package:analysis_server/src/package_map_provider.dart'; | 10 import 'package:analysis_server/src/package_map_provider.dart'; |
| 11 import 'package:analysis_server/src/resource.dart'; | 11 import 'package:analysis_server/src/resource.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:watcher/watcher.dart'; | 14 import 'package:watcher/watcher.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Information tracked by the [ContextDirectoryManager] for each context. | 17 * Information tracked by the [ContextDirectoryManager] for each context. |
| 18 */ | 18 */ |
| 19 class _ContextDirectoryInfo { | 19 class _ContextDirectoryInfo { |
| 20 /** | 20 /** |
| 21 * Stream subscription we are using to watch the context's directory for | 21 * Stream subscription we are using to watch the context's directory for |
| 22 * changes. | 22 * changes. |
| 23 */ | 23 */ |
| 24 StreamSubscription<WatchEvent> changeSubscription; | 24 StreamSubscription<WatchEvent> changeSubscription; |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Map from full path to the [Source] object, for each source that has been | 27 * Map from full path to the [Source] object, for each source that has been |
| 28 * added to the context. | 28 * added to the context. |
| 29 */ | 29 */ |
| 30 HashMap<String, Source> sources = new HashMap<String, Source>(); | 30 Map<String, Source> sources = new HashMap<String, Source>(); |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Dependencies of the context's package map. If any of these files changes, | 33 * Dependencies of the context's package map. If any of these files changes, |
| 34 * the package map needs to be recomputed. | 34 * the package map needs to be recomputed. |
| 35 */ | 35 */ |
| 36 Set<String> packageMapDependencies; | 36 Set<String> packageMapDependencies; |
| 37 } | 37 } |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Class that maintains a mapping from included/excluded paths to a set of | 40 * Class that maintains a mapping from included/excluded paths to a set of |
| 41 * folders that should correspond to analysis contexts. | 41 * folders that should correspond to analysis contexts. |
| 42 */ | 42 */ |
| 43 abstract class ContextDirectoryManager { | 43 abstract class ContextDirectoryManager { |
| 44 /** | 44 /** |
| 45 * File name of pubspec files. | 45 * File name of pubspec files. |
| 46 */ | 46 */ |
| 47 static const String PUBSPEC_NAME = 'pubspec.yaml'; | 47 static const String PUBSPEC_NAME = 'pubspec.yaml'; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * [_ContextDirectoryInfo] object for each included directory in the most | 50 * [_ContextDirectoryInfo] object for each included directory in the most |
| 51 * recent successful call to [setRoots]. | 51 * recent successful call to [setRoots]. |
| 52 */ | 52 */ |
| 53 HashMap<Folder, _ContextDirectoryInfo> _currentDirectoryInfo = | 53 Map<Folder, _ContextDirectoryInfo> _currentDirectoryInfo = |
| 54 new HashMap<Folder, _ContextDirectoryInfo>(); | 54 new HashMap<Folder, _ContextDirectoryInfo>(); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * The [ResourceProvider] using which paths are converted into [Resource]s. | 57 * The [ResourceProvider] using which paths are converted into [Resource]s. |
| 58 */ | 58 */ |
| 59 final ResourceProvider resourceProvider; | 59 final ResourceProvider resourceProvider; |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Provider which is used to determine the mapping from package name to | 62 * Provider which is used to determine the mapping from package name to |
| 63 * package folder. | 63 * package folder. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // editing and has unsaved changes (e.g. having unsaved changes to | 236 // editing and has unsaved changes (e.g. having unsaved changes to |
| 237 // 'foo.dart' causes a link '.#foo.dart' to be created, which points to the | 237 // 'foo.dart' causes a link '.#foo.dart' to be created, which points to the |
| 238 // non-existent file 'username@hostname.pid'. To avoid these dummy links | 238 // non-existent file 'username@hostname.pid'. To avoid these dummy links |
| 239 // causing the analyzer to thrash, just ignore links to non-existent files. | 239 // causing the analyzer to thrash, just ignore links to non-existent files. |
| 240 return file.exists; | 240 return file.exists; |
| 241 } | 241 } |
| 242 | 242 |
| 243 /** | 243 /** |
| 244 * Called when a new context needs to be created. | 244 * Called when a new context needs to be created. |
| 245 */ | 245 */ |
| 246 void addContext(Folder folder, HashMap<String, List<Folder>> packageMap); | 246 void addContext(Folder folder, Map<String, List<Folder>> packageMap); |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * Called when the set of files associated with a context have changed (or | 249 * Called when the set of files associated with a context have changed (or |
| 250 * some of those files have been modified). [changeSet] is the set of | 250 * some of those files have been modified). [changeSet] is the set of |
| 251 * changes that need to be applied to the context. | 251 * changes that need to be applied to the context. |
| 252 */ | 252 */ |
| 253 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); | 253 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); |
| 254 | 254 |
| 255 /** | 255 /** |
| 256 * Remove the context associated with the given [folder]. | 256 * Remove the context associated with the given [folder]. |
| 257 */ | 257 */ |
| 258 void removeContext(Folder folder); | 258 void removeContext(Folder folder); |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Called when the package map for a context has changed. | 261 * Called when the package map for a context has changed. |
| 262 */ | 262 */ |
| 263 void updateContextPackageMap(Folder contextFolder, | 263 void updateContextPackageMap(Folder contextFolder, |
| 264 Map<String, List<Folder>> packageMap); | 264 Map<String, List<Folder>> packageMap); |
| 265 } | 265 } |
| OLD | NEW |