| 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'; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 * Create a new context associated with the given folder. | 111 * Create a new context associated with the given folder. |
| 112 */ | 112 */ |
| 113 void _createContext(Folder folder) { | 113 void _createContext(Folder folder) { |
| 114 _ContextDirectoryInfo info = new _ContextDirectoryInfo(); | 114 _ContextDirectoryInfo info = new _ContextDirectoryInfo(); |
| 115 _currentDirectoryInfo[folder] = info; | 115 _currentDirectoryInfo[folder] = info; |
| 116 info.changeSubscription = folder.changes.listen((WatchEvent event) { | 116 info.changeSubscription = folder.changes.listen((WatchEvent event) { |
| 117 _handleWatchEvent(folder, info, event); | 117 _handleWatchEvent(folder, info, event); |
| 118 }); | 118 }); |
| 119 File pubspecFile = folder.getChild(PUBSPEC_NAME); | 119 File pubspecFile = folder.getChild(PUBSPEC_NAME); |
| 120 PackageMapInfo packageMapInfo = packageMapProvider.computePackageMap(folder)
; | 120 PackageMapInfo packageMapInfo = packageMapProvider.computePackageMap(folder)
; |
| 121 // TODO(paulberry): handle null return from computePackageMap. | |
| 122 info.packageMapDependencies = packageMapInfo.dependencies; | 121 info.packageMapDependencies = packageMapInfo.dependencies; |
| 123 // TODO(paulberry): if any of the dependencies is outside of [folder], | 122 // TODO(paulberry): if any of the dependencies is outside of [folder], |
| 124 // we'll need to watch their parent folders as well. | 123 // we'll need to watch their parent folders as well. |
| 125 addContext(folder, packageMapInfo.packageMap); | 124 addContext(folder, packageMapInfo.packageMap); |
| 126 ChangeSet changeSet = new ChangeSet(); | 125 ChangeSet changeSet = new ChangeSet(); |
| 127 _addSourceFiles(changeSet, folder, info); | 126 _addSourceFiles(changeSet, folder, info); |
| 128 applyChangesToContext(folder, changeSet); | 127 applyChangesToContext(folder, changeSet); |
| 129 } | 128 } |
| 130 | 129 |
| 131 /** | 130 /** |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 177 } |
| 179 break; | 178 break; |
| 180 } | 179 } |
| 181 | 180 |
| 182 if (info.packageMapDependencies.contains(event.path)) { | 181 if (info.packageMapDependencies.contains(event.path)) { |
| 183 // TODO(paulberry): when computePackageMap is changed into an | 182 // TODO(paulberry): when computePackageMap is changed into an |
| 184 // asynchronous API call, we'll want to suspend analysis for this context | 183 // asynchronous API call, we'll want to suspend analysis for this context |
| 185 // while we're rerunning "pub list", since any analysis we complete while | 184 // while we're rerunning "pub list", since any analysis we complete while |
| 186 // "pub list" is in progress is just going to get thrown away anyhow. | 185 // "pub list" is in progress is just going to get thrown away anyhow. |
| 187 PackageMapInfo packageMapInfo = packageMapProvider.computePackageMap(folde
r); | 186 PackageMapInfo packageMapInfo = packageMapProvider.computePackageMap(folde
r); |
| 188 // TODO(paulberry): handle null return from computePackageMap. | |
| 189 info.packageMapDependencies = packageMapInfo.dependencies; | 187 info.packageMapDependencies = packageMapInfo.dependencies; |
| 190 updateContextPackageMap(folder, packageMapInfo.packageMap); | 188 updateContextPackageMap(folder, packageMapInfo.packageMap); |
| 191 } | 189 } |
| 192 } | 190 } |
| 193 | 191 |
| 194 /** | 192 /** |
| 195 * Determine if the path from [folder] to [path] contains a 'packages' | 193 * Determine if the path from [folder] to [path] contains a 'packages' |
| 196 * directory. | 194 * directory. |
| 197 */ | 195 */ |
| 198 bool _isInPackagesDir(String path, Folder folder) { | 196 bool _isInPackagesDir(String path, Folder folder) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 * Remove the context associated with the given [folder]. | 248 * Remove the context associated with the given [folder]. |
| 251 */ | 249 */ |
| 252 void removeContext(Folder folder); | 250 void removeContext(Folder folder); |
| 253 | 251 |
| 254 /** | 252 /** |
| 255 * Called when the package map for a context has changed. | 253 * Called when the package map for a context has changed. |
| 256 */ | 254 */ |
| 257 void updateContextPackageMap(Folder contextFolder, | 255 void updateContextPackageMap(Folder contextFolder, |
| 258 Map<String, List<Folder>> packageMap); | 256 Map<String, List<Folder>> packageMap); |
| 259 } | 257 } |
| OLD | NEW |